URLConnection.guessContentTypeFromStream
Class Overview | Class Members |
This Package |
All Packages
public static String guessContentTypeFromStream( InputStream is ) throws IOException
Parameters
- is
- an input stream that supports marks.
Returns
a guess at the content type, or null if none
can be determined.
Description
Tries to determine the type of an input stream based on the
characters at the beginning of the input stream. This method can
be used by subclasses that override the
getContentType method.
Ideally, this routine would not be needed. But many
http servers return the incorrect content type; in
addition, there are many nonstandard extensions. Direct inspection
of the bytes to determine the content type is often more accurate
than believing the content type claimed by the http server.
Exceptions
IOException
if an I/O error occurs while reading the
input stream.
See Also
mark, markSupported, getContentType