Here you can find the source of getMimeType(String file)
public static String getMimeType(String file)
//package com.java2s; //License from project: Open Source License import java.net.FileNameMap; import java.net.URLConnection; public class Main { public static String getMimeType(String file) { FileNameMap fileNameMap = URLConnection.getFileNameMap(); String type = fileNameMap.getContentTypeFor(file); return type; }//w w w .j a v a 2s . c o m }