Java tutorial
//package com.java2s; //License from project: Apache License import java.net.FileNameMap; import java.net.URLConnection; public class Main { public static String getMimeType(String path) { FileNameMap fileNameMap = URLConnection.getFileNameMap(); String contentTypeFor = fileNameMap.getContentTypeFor(path); if (contentTypeFor == null) { contentTypeFor = "application/octet-stream"; } return contentTypeFor; } }