Here you can find the source of getMimeType(String fileName)
public static String getMimeType(String fileName)
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class Main { public static String getMimeType(String fileName) { try {//w w w .ja v a2 s . c o m return Files.probeContentType(Paths.get(fileName)); } catch (IOException e) { return "application/octet-stream"; } /* * Collection types = MimeUtil.getMimeTypes(fileName); return * MimeUtil2.getMostSpecificMimeType(types).toString(); */ } }