Here you can find the source of getContentType(final File file)
Parameter | Description |
---|---|
file | a parameter |
public static String getContentType(final File file)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.net.FileNameMap; import java.net.URLConnection; public class Main { /** For looking up file mime types. */ private static final FileNameMap MIMETYPES = URLConnection.getFileNameMap(); /**/*w w w. j a v a2 s. c o m*/ * Get a file mime type based on its filename. * * Calls getContentType(file.getName()). * * @param file * @return String mime type. */ public static String getContentType(final File file) { return getContentType(file.getName()); } /** * Get a file mime type based on its file path extension. * * Uses URLConnection.getFileNameMap(). * * @param filename * file path. * @return String mime type. */ public static String getContentType(final String filename) { return MIMETYPES.getContentTypeFor(filename); } }