I need a method for checking the MIME-type file.
For this purpose, I used the probeContentType () method.

What are the alternatives for detecting MIME-type in files?

class ProbeContentTypeCheker implements Checker { @Override public boolean check(File currentFile) { try { Path filePath = FileSystems.getDefault().getPath( currentFile.getAbsolutePath()); if ((Files.probeContentType(filePath) != null)) { return true; } } catch (IOException e) { e.printStackTrace(); } return false; } } 
  • The answer to the SO did not suit you? :) - a_gura
  • @a_gura if arranged did not ask. - nazar_art
  • And what does not suit this way? The MIME-type in the probeContentType is determined based on the byte order and file extension. This of course does not always work. You can specify any extension, but magic bytes may be appropriate in binary files, but the content will not actually be of this type. - iksuy

0