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