public String detect(File file) throws IOException {
        Metadata metadata = new Metadata();
        try (@SuppressWarnings("deprecation") InputStream stream = TikaInputStream
                .get(file, metadata)) {
            return detect(stream, metadata);
        }
    }
Detects the media type of the given file. The type detection is
based on the document content and a potential known file extension.
<p>
Use the {@link #detect(String)} method when you want to detect the
type of the document without actually accessing the file.

@param file the file
@return detected media type
@throws IOException if the file can not be read
@see #detect(Path)
tika-core/src/main/java/org/apache/tika/Tika.java