I was just wondering how most people fetch a mime type from a file in Java? So far I\'ve tried two utils: JMimeMagic
& Mime-Util
.
Th
public String getFileContentType(String fileName) {
String fileType = "Undetermined";
final File file = new File(fileName);
try
{
fileType = Files.probeContentType(file.toPath());
}
catch (IOException ioException)
{
System.out.println(
"ERROR: Unable to determine file type for " + fileName
+ " due to exception " + ioException);
}
return fileType;
}