I\'m adding some functionality to a program so that I can accurately determine the files type by reading the MIME data. I\'ve already tried a few methods:
Method 1:
I'm not entirely sure how accurate it is, but this worked for me in simple cases.
FileNameMap fileNameMap = URLConnection.getFileNameMap(); String type = fileNameMap.getContentTypeFor(filePath);