Here you can find the source of getContentType(File file)
public static String getContentType(File file)
//package com.java2s; //License from project: Apache License import java.io.File; import java.net.URLConnection; public class Main { public static String getContentType(File file) { String contentType = (URLConnection.guessContentTypeFromName(file .getName()));/* w w w. ja v a 2 s . c om*/ if ("".equals(contentType) || contentType == null) { if (file.getName().contains(".jhtml")) { contentType = "text/jhtml"; } if (file.getName().contains(".jap")) { contentType = "application/jap"; } if (file.getName().contains(".css")) { contentType = "text/css"; } if (file.getName().contains(".js")) { contentType = "text/javascript"; } } return contentType; } }