code: 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;
  	}
docs: Identify the mime type of a file.
  
  @param file the File to detect.
  @return mime type as detected by Apache tika, otherwise null.