Reputation: 55
I'm buliding an application similar to a URL crawler wherein I need differentiate between a normal webpage and a pdf or img or doc. Tried all ways of MIMETYPE checks... :(
Upvotes: 1
Views: 1251
Reputation: 869
That will do the job:
URL url = new URL(adress);
URLConnection u = url.openConnection();
String type = u.getHeaderField("Content-Type");
return type;
Returns
text/html; charset=utf-8
for this page.
Upvotes: 1