public static String getFileMimeType ( final File file ) { if ( file != null ) { try { final Tika tika = new Tika ( ) ; return tika . detect ( file . getInputStream ( ) ) ; } catch ( IOException ex ) { LOG . error ( "Invalid file, name " + file . getName ( ) , ex ) ; } } return null ; }
Identify the mime type of a file .