Here you can find the source of getContentType(String fileName)
public static String getContentType(String fileName)
//package com.java2s; //License from project: Apache License import java.net.URLConnection; public class Main { public static String getContentType(String fileName) { return URLConnection.guessContentTypeFromName(fileName); }//from w ww . j a va 2 s . c o m }