【问题标题】:Is there any method to deduct content type from File [duplicate]有什么方法可以从文件中扣除内容类型[重复] 【发布时间】:2011-07-12 11:45:50 【问题描述】: 可能重复:Getting A File's Mime Type In Java 有一个文件,有没有办法扣除它的内容类型,如 application/xml 等? 【问题讨论】: 标签: java file mime-types mime 【解决方案1】: new MimetypesFileTypeMap().getContentType(new File("yourFile")); 另见 getContentType(File f) 【讨论】: 【解决方案2】: 试试jMimeMagic 和Mime Type Detection Utility 取自:How to detect files type 【讨论】: