Detects the media type of the given document. The type detection is based on the content of the given document stream and any given document metadata. The document stream can be
null
, in which case only the given document metadata is used for type detection.
If the document stream supports the {@link InputStream#markSupported() mark feature}, then the stream is marked and reset to the original position before this method returns. Only a limited number of bytes are read from the stream.
The given document stream is not closed by this method.
Unlike in the {@link #parse(InputStream,Metadata)} method, thegiven document metadata is not modified by this method.
@param stream the document stream, or null
@param metadata document metadata
@return detected media type
@throws IOException if the stream can not be read