Here you can find the source of getMIMEType(String fileName)
Parameter | Description |
---|---|
fileName | The file name to be analyzed |
public static String getMIMEType(String fileName)
//package com.java2s; //License from project: MIT License import java.io.File; import java.net.FileNameMap; import java.net.URLConnection; public class Main { /**/*from w w w.j a va 2s . c om*/ * Returns the MIME type of the given file name. * * @param fileName The file name to be analyzed * @return The MIME type */ public static String getMIMEType(String fileName) { FileNameMap fileNameMap = URLConnection.getFileNameMap(); return fileNameMap.getContentTypeFor(fileName); } /** * Returns the MIME type of the given {@link File}. * * @param file The {@code File} to be analyzed * @return The MIME type */ public static String getMIMEType(File file) { FileNameMap fileNameMap = URLConnection.getFileNameMap(); return fileNameMap.getContentTypeFor(file.getName()); } }