![]() |
This code:
works properly for files that exist, but gives a NullPointerException on non-existent files.URLConnection conn = url.openConnection(); conn.connect(); String contentType = conn.getContentType();
Inserting this:
InputStream f = conn.getInputStream();
before the getContentType() gives the proper FileNotFoundException.
Looks like either there are some missing checks, or you need to document that getInputStream() has to be called first.