Java tutorial
//package com.java2s; //License from project: LGPL import java.net.FileNameMap; import java.net.URLConnection; public class Main { public static String getMimeTypeForFile(String path) { FileNameMap fileNameMap = URLConnection.getFileNameMap(); return fileNameMap.getContentTypeFor(path); } }