Gets the type of mine type of the file

Source: Internet
Author: User
Tags rar webp

Say the mine type of the commonly used files:

MIME Type File Extensions
Application/msword Doc
Application/pdf 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 programmatic way to get:

Environment, dependent jars:

<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);
	}








Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.