This method should be check if a file is MIME type. To achieve this goal I am using method probeContentType().
However maybe is another way to decide same question. Which are the other alternatives (if there are any)?
Code:
class ProbeContentTypeCheker implements Checker {
    @Override
    public boolean check(File fileCheck) {
        try {
            Path filePath = FileSystems.getDefault().getPath(
                    fileCheck.getAbsolutePath());
            if ((Files.probeContentType(filePath) != null)) {
                return true;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return false;
    }
}
Question:
There are 2 approaches for getting a file mime type:
The following solution use the 1st approach:
The following solution use the 2nd approach:
For some more information see this post
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With