When I use something like:
URL url = new URL(a_url);
URLConnection url_conn = url.openConnection();
Object content = url_conn.getContent();
and the MIME type of the file retrieved is HTML or XML I debugged that
content at run-time will contain an instance of:
sun.net.www.protocol.http.HttpURLConnection$HttpInputStream
Now if I want to use instanceof on that instance how can I do?
if (content instanceof PlainTextInputStream)
{
...
}
else if(content instanceof ImageProducer)
{
...
}
else if(content instanceof ???) {}
You should not depend of implementation classes. It will break someday.
I think this how you should do it based on the request headers:
Read more about Content-Type here: