标签:
需求:
实现步骤:
1. 获得获取文件的扩展名
private static String getExtension(final File file) { String suffix = ""; String name = file.getName(); final int idx = name.lastIndexOf("."); if (idx > 0) { suffix = name.substring(idx + 1); } return suffix; }
public static String getMimeType(final File file) { String extension = getExtension(file); return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); }
标签:
原文地址:http://blog.csdn.net/programs/article/details/42810149