说一下常用的文件的mine type类型:
MIME type | File extensions |
---|---|
application/msword | doc |
application/pdf | |
application/rtf | rtf |
application/vnd.ms-excel | xls |
application/vnd.ms-powerpoint | ppt |
application/x-rar-compressed | rar |
application/x-shockwave-flash | swf |
application/zip | zip |
audio/midi | mid midi kar |
audio/mpeg | mp3 |
audio/ogg | ogg |
audio/x-m4a | m4a |
audio/x-realaudio | ra |
image/gif | gif |
image/jpeg | jpeg jpg |
image/png | png |
image/tiff | tif tiff |
image/vnd.wap.wbmp | wbmp |
image/x-icon | ico |
image/x-jng | jng |
image/x-ms-bmp | bmp |
image/svg+xml | svg svgz |
image/webp | webp |
text/css | css |
text/html | html htm shtml |
text/plain | txt |
text/xml | xml |
video/3gpp | 3gpp 3gp |
video/mp4 | mp4 |
video/mpeg | mpeg mpg |
video/quicktime | mov |
video/webm | webm |
video/x-flv | flv |
video/x-m4v | m4v |
video/x-ms-wmv | wmv |
video/x-msvideo | avi |
java编程方式获取:
环境,依赖的jar:
<dependency>
<groupId>eu.medsea.mimeutil</groupId>
<artifactId>mime-util</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.13</version>
</dependency>
Test:
import java.io.File;
import java.util.Collection;
import eu.medsea.mimeutil.MimeUtil;
public class MineTypeTest {
public static void main(String[] args) {
MimeUtil.registerMimeDetector("eu.medsea.mimeutil.detector.MagicMimeMimeDetector");
//File f = new File("e:/chatdemo-ui.apk");
File f = new File("e:/111.jpg");
Collection<?> mimeTypes = MimeUtil.getMimeTypes(f);
System.out.println(mimeTypes);
}
}