Here you can find the source of getContentType(String filePath)
Parameter | Description |
---|---|
filePath | the file path and name |
public static final String getContentType(String filePath)
//package com.java2s; import javax.activation.FileTypeMap; import javax.activation.MimetypesFileTypeMap; public class Main { /**/*from ww w. j av a 2 s .c om*/ * Returns the mime type of the given file. * @param filePath the file path and name * @return String */ public static final String getContentType(String filePath) { FileTypeMap map = MimetypesFileTypeMap.getDefaultFileTypeMap(); return map.getContentType(filePath); } }