开发者社区> 欧阳鹏> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

我的Android进阶之旅------>MIME类型大全

简介: 今天在实现一个安装apk的代码中看到一段代码为:application/vnd.android.package-archive,不知其意,所以百度了一下,了解到这是一种MIME的类型,代表apk类型。
+关注继续查看
今天在实现一个安装apk的代码中看到一段代码为:application/vnd.android.package-archive,不知其意,所以百度了一下,了解到这是一种MIME的类型,代表apk类型。
代码如下:
//安装apk   
 protected void installApk(File file) {  
    Intent intent = new Intent();  
    //执行动作  
    intent.setAction(Intent.ACTION_VIEW);  
    //执行的数据类型  
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");  
    startActivity(intent);  
} 


格式前面为后缀名,后面为对应的MIME型
(例如: ".apk", "application/vnd.android.package-archive" 表示。.apk对应的是application/vnd.android.package-archive
import java.io.File;

public class MimeTest {
	/**
	 * MIME全部类型映射
	 */
	final static String[][] MIME_MapTable = {
			{ ".323", "text/h323" },
			{ ".3gp", "video/3gpp" },
			{ ".aab", "application/x-authoware-bin" },
			{ ".aam", "application/x-authoware-map" },
			{ ".aas", "application/x-authoware-seg" },
			{ ".acx", "application/internet-property-stream" },
			{ ".ai", "application/postscript" },
			{ ".aif", "audio/x-aiff" },
			{ ".aifc", "audio/x-aiff" },
			{ ".aiff", "audio/x-aiff" },
			{ ".als", "audio/X-Alpha5" },
			{ ".amc", "application/x-mpeg" },
			{ ".ani", "application/octet-stream" },
			{ ".apk", "application/vnd.android.package-archive" },
			{ ".asc", "text/plain" },
			{ ".asd", "application/astound" },
			{ ".asf", "video/x-ms-asf" },
			{ ".asn", "application/astound" },
			{ ".asp", "application/x-asap" },
			{ ".asr", "video/x-ms-asf" },
			{ ".asx", "video/x-ms-asf" },
			{ ".au", "audio/basic" },
			{ ".avb", "application/octet-stream" },
			{ ".avi", "video/x-msvideo" },
			{ ".awb", "audio/amr-wb" },
			{ ".axs", "application/olescript" },
			{ ".bas", "text/plain" },
			{ ".bcpio", "application/x-bcpio" },
			{ ".bin ", "application/octet-stream" },
			{ ".bld", "application/bld" },
			{ ".bld2", "application/bld2" },
			{ ".bmp", "image/bmp" },
			{ ".bpk", "application/octet-stream" },
			{ ".bz2", "application/x-bzip2" },
			{ ".c", "text/plain" },
			{ ".cal", "image/x-cals" },
			{ ".cat", "application/vnd.ms-pkiseccat" },
			{ ".ccn", "application/x-cnc" },
			{ ".cco", "application/x-cocoa" },
			{ ".cdf", "application/x-cdf" },
			{ ".cer", "application/x-x509-ca-cert" },
			{ ".cgi", "magnus-internal/cgi" },
			{ ".chat", "application/x-chat" },
			{ ".class", "application/octet-stream" },
			{ ".clp", "application/x-msclip" },
			{ ".cmx", "image/x-cmx" },
			{ ".co", "application/x-cult3d-object" },
			{ ".cod", "image/cis-cod" },
			{ ".conf", "text/plain" },
			{ ".cpio", "application/x-cpio" },
			{ ".cpp", "text/plain" },
			{ ".cpt", "application/mac-compactpro" },
			{ ".crd", "application/x-mscardfile" },
			{ ".crl", "application/pkix-crl" },
			{ ".crt", "application/x-x509-ca-cert" },
			{ ".csh", "application/x-csh" },
			{ ".csm", "chemical/x-csml" },
			{ ".csml", "chemical/x-csml" },
			{ ".css", "text/css" },
			{ ".cur", "application/octet-stream" },
			{ ".dcm", "x-lml/x-evm" },
			{ ".dcr", "application/x-director" },
			{ ".dcx", "image/x-dcx" },
			{ ".der", "application/x-x509-ca-cert" },
			{ ".dhtml", "text/html" },
			{ ".dir", "application/x-director" },
			{ ".dll", "application/x-msdownload" },
			{ ".dmg", "application/octet-stream" },
			{ ".dms", "application/octet-stream" },
			{ ".doc", "application/msword" },
			{ ".docx",
					"application/vnd.openxmlformats-officedocument.wordprocessingml.document" },
			{ ".dot", "application/msword" },
			{ ".dvi", "application/x-dvi" },
			{ ".dwf", "drawing/x-dwf" },
			{ ".dwg", "application/x-autocad" },
			{ ".dxf", "application/x-autocad" },
			{ ".dxr", "application/x-director" },
			{ ".ebk", "application/x-expandedbook" },
			{ ".emb", "chemical/x-embl-dl-nucleotide" },
			{ ".embl", "chemical/x-embl-dl-nucleotide" },
			{ ".eps", "application/postscript" },
			{ ".epub", "application/epub+zip" },
			{ ".eri", "image/x-eri" },
			{ ".es", "audio/echospeech" },
			{ ".esl", "audio/echospeech" },
			{ ".etc", "application/x-earthtime" },
			{ ".etx", "text/x-setext" },
			{ ".evm", "x-lml/x-evm" },
			{ ".evy", "application/envoy" },
			{ ".exe", "application/octet-stream" },
			{ ".fh4", "image/x-freehand" },
			{ ".fh5", "image/x-freehand" },
			{ ".fhc", "image/x-freehand" },
			{ ".fif", "application/fractals" },
			{ ".flr", "x-world/x-vrml" },
			{ ".flv", "flv-application/octet-stream" },
			{ ".fm", "application/x-maker" },
			{ ".fpx", "image/x-fpx" },
			{ ".fvi", "video/isivideo" },
			{ ".gau", "chemical/x-gaussian-input" },
			{ ".gca", "application/x-gca-compressed" },
			{ ".gdb", "x-lml/x-gdb" },
			{ ".gif", "image/gif" },
			{ ".gps", "application/x-gps" },
			{ ".gtar", "application/x-gtar" },
			{ ".gz", "application/x-gzip" },
			{ ".h", "text/plain" },
			{ ".hdf", "application/x-hdf" },
			{ ".hdm", "text/x-hdml" },
			{ ".hdml", "text/x-hdml" },
			{ ".hlp", "application/winhlp" },
			{ ".hqx", "application/mac-binhex40" },
			{ ".hta", "application/hta" },
			{ ".htc", "text/x-component" },
			{ ".htm", "text/html" },
			{ ".html", "text/html" },
			{ ".hts", "text/html" },
			{ ".htt", "text/webviewhtml" },
			{ ".ice", "x-conference/x-cooltalk" },
			{ ".ico", "image/x-icon" },
			{ ".ief", "image/ief" },
			{ ".ifm", "image/gif" },
			{ ".ifs", "image/ifs" },
			{ ".iii", "application/x-iphone" },
			{ ".imy", "audio/melody" },
			{ ".ins", "application/x-internet-signup" },
			{ ".ips", "application/x-ipscript" },
			{ ".ipx", "application/x-ipix" },
			{ ".isp", "application/x-internet-signup" },
			{ ".it", "audio/x-mod" },
			{ ".itz", "audio/x-mod" },
			{ ".ivr", "i-world/i-vrml" },
			{ ".j2k", "image/j2k" },
			{ ".jad", "text/vnd.sun.j2me.app-descriptor" },
			{ ".jam", "application/x-jam" },
			{ ".jar", "application/java-archive" },
			{ ".java", "text/plain" },
			{ ".jfif", "image/pipeg" },
			{ ".jnlp", "application/x-java-jnlp-file" },
			{ ".jpe", "image/jpeg" },
			{ ".jpeg", "image/jpeg" },
			{ ".jpg", "image/jpeg" },
			{ ".jpz", "image/jpeg" },
			{ ".js", "application/x-javascript" },
			{ ".jwc", "application/jwc" },
			{ ".kjx", "application/x-kjx" },
			{ ".lak", "x-lml/x-lak" },
			{ ".latex", "application/x-latex" },
			{ ".lcc", "application/fastman" },
			{ ".lcl", "application/x-digitalloca" },
			{ ".lcr", "application/x-digitalloca" },
			{ ".lgh", "application/lgh" },
			{ ".lha", "application/octet-stream" },
			{ ".lml", "x-lml/x-lml" },
			{ ".lmlpack", "x-lml/x-lmlpack" },
			{ ".log", "text/plain" },
			{ ".lsf", "video/x-la-asf" },
			{ ".lsx", "video/x-la-asf" },
			{ ".lzh", "application/octet-stream" },
			{ ".m13", "application/x-msmediaview" },
			{ ".m14", "application/x-msmediaview" },
			{ ".m15", "audio/x-mod" },
			{ ".m3u", "audio/x-mpegurl" },
			{ ".m3url", "audio/x-mpegurl" },
			{ ".m4a", "audio/mp4a-latm" },
			{ ".m4b", "audio/mp4a-latm" },
			{ ".m4p", "audio/mp4a-latm" },
			{ ".m4u", "video/vnd.mpegurl" },
			{ ".m4v", "video/x-m4v" },
			{ ".ma1", "audio/ma1" },
			{ ".ma2", "audio/ma2" },
			{ ".ma3", "audio/ma3" },
			{ ".ma5", "audio/ma5" },
			{ ".man", "application/x-troff-man" },
			{ ".map", "magnus-internal/imagemap" },
			{ ".mbd", "application/mbedlet" },
			{ ".mct", "application/x-mascot" },
			{ ".mdb", "application/x-msaccess" },
			{ ".mdz", "audio/x-mod" },
			{ ".me", "application/x-troff-me" },
			{ ".mel", "text/x-vmel" },
			{ ".mht", "message/rfc822" },
			{ ".mhtml", "message/rfc822" },
			{ ".mi", "application/x-mif" },
			{ ".mid", "audio/mid" },
			{ ".midi", "audio/midi" },
			{ ".mif", "application/x-mif" },
			{ ".mil", "image/x-cals" },
			{ ".mio", "audio/x-mio" },
			{ ".mmf", "application/x-skt-lbs" },
			{ ".mng", "video/x-mng" },
			{ ".mny", "application/x-msmoney" },
			{ ".moc", "application/x-mocha" },
			{ ".mocha", "application/x-mocha" },
			{ ".mod", "audio/x-mod" },
			{ ".mof", "application/x-yumekara" },
			{ ".mol", "chemical/x-mdl-molfile" },
			{ ".mop", "chemical/x-mopac-input" },
			{ ".mov", "video/quicktime" },
			{ ".movie", "video/x-sgi-movie" },
			{ ".mp2", "video/mpeg" },
			{ ".mp3", "audio/mpeg" },
			{ ".mp4", "video/mp4" },
			{ ".mpa", "video/mpeg" },
			{ ".mpc", "application/vnd.mpohun.certificate" },
			{ ".mpe", "video/mpeg" },
			{ ".mpeg", "video/mpeg" },
			{ ".mpg", "video/mpeg" },
			{ ".mpg4", "video/mp4" },
			{ ".mpga", "audio/mpeg" },
			{ ".mpn", "application/vnd.mophun.application" },
			{ ".mpp", "application/vnd.ms-project" },
			{ ".mps", "application/x-mapserver" },
			{ ".mpv2", "video/mpeg" },
			{ ".mrl", "text/x-mrml" },
			{ ".mrm", "application/x-mrm" },
			{ ".ms", "application/x-troff-ms" },
			{ ".msg", "application/vnd.ms-outlook" },
			{ ".mts", "application/metastream" },
			{ ".mtx", "application/metastream" },
			{ ".mtz", "application/metastream" },
			{ ".mvb", "application/x-msmediaview" },
			{ ".mzv", "application/metastream" },
			{ ".nar", "application/zip" },
			{ ".nbmp", "image/nbmp" },
			{ ".nc", "application/x-netcdf" },
			{ ".ndb", "x-lml/x-ndb" },
			{ ".ndwn", "application/ndwn" },
			{ ".nif", "application/x-nif" },
			{ ".nmz", "application/x-scream" },
			{ ".nokia-op-logo", "image/vnd.nok-oplogo-color" },
			{ ".npx", "application/x-netfpx" },
			{ ".nsnd", "audio/nsnd" },
			{ ".nva", "application/x-neva1" },
			{ ".nws", "message/rfc822" },
			{ ".oda", "application/oda" },
			{ ".ogg", "audio/ogg" },
			{ ".oom", "application/x-AtlasMate-Plugin" },
			{ ".p10", "application/pkcs10" },
			{ ".p12", "application/x-pkcs12" },
			{ ".p7b", "application/x-pkcs7-certificates" },
			{ ".p7c", "application/x-pkcs7-mime" },
			{ ".p7m", "application/x-pkcs7-mime" },
			{ ".p7r", "application/x-pkcs7-certreqresp" },
			{ ".p7s", "application/x-pkcs7-signature" },
			{ ".pac", "audio/x-pac" },
			{ ".pae", "audio/x-epac" },
			{ ".pan", "application/x-pan" },
			{ ".pbm", "image/x-portable-bitmap" },
			{ ".pcx", "image/x-pcx" },
			{ ".pda", "image/x-pda" },
			{ ".pdb", "chemical/x-pdb" },
			{ ".pdf", "application/pdf" },
			{ ".pfr", "application/font-tdpfr" },
			{ ".pfx", "application/x-pkcs12" },
			{ ".pgm", "image/x-portable-graymap" },
			{ ".pict", "image/x-pict" },
			{ ".pko", "application/ynd.ms-pkipko" },
			{ ".pm", "application/x-perl" },
			{ ".pma", "application/x-perfmon" },
			{ ".pmc", "application/x-perfmon" },
			{ ".pmd", "application/x-pmd" },
			{ ".pml", "application/x-perfmon" },
			{ ".pmr", "application/x-perfmon" },
			{ ".pmw", "application/x-perfmon" },
			{ ".png", "image/png" },
			{ ".pnm", "image/x-portable-anymap" },
			{ ".pnz", "image/png" },
			{ ".pot,", "application/vnd.ms-powerpoint" },
			{ ".ppm", "image/x-portable-pixmap" },
			{ ".pps", "application/vnd.ms-powerpoint" },
			{ ".ppt", "application/vnd.ms-powerpoint" },
			{ ".pptx",
					"application/vnd.openxmlformats-officedocument.presentationml.presentation" },
			{ ".pqf", "application/x-cprplayer" },
			{ ".pqi", "application/cprplayer" },
			{ ".prc", "application/x-prc" },
			{ ".prf", "application/pics-rules" },
			{ ".prop", "text/plain" },
			{ ".proxy", "application/x-ns-proxy-autoconfig" },
			{ ".ps", "application/postscript" },
			{ ".ptlk", "application/listenup" },
			{ ".pub", "application/x-mspublisher" },
			{ ".pvx", "video/x-pv-pvx" },
			{ ".qcp", "audio/vnd.qcelp" },
			{ ".qt", "video/quicktime" },
			{ ".qti", "image/x-quicktime" },
			{ ".qtif", "image/x-quicktime" },
			{ ".r3t", "text/vnd.rn-realtext3d" },
			{ ".ra", "audio/x-pn-realaudio" },
			{ ".ram", "audio/x-pn-realaudio" },
			{ ".rar", "application/octet-stream" },
			{ ".ras", "image/x-cmu-raster" },
			{ ".rc", "text/plain" },
			{ ".rdf", "application/rdf+xml" },
			{ ".rf", "image/vnd.rn-realflash" },
			{ ".rgb", "image/x-rgb" },
			{ ".rlf", "application/x-richlink" },
			{ ".rm", "audio/x-pn-realaudio" },
			{ ".rmf", "audio/x-rmf" },
			{ ".rmi", "audio/mid" },
			{ ".rmm", "audio/x-pn-realaudio" },
			{ ".rmvb", "audio/x-pn-realaudio" },
			{ ".rnx", "application/vnd.rn-realplayer" },
			{ ".roff", "application/x-troff" },
			{ ".rp", "image/vnd.rn-realpix" },
			{ ".rpm", "audio/x-pn-realaudio-plugin" },
			{ ".rt", "text/vnd.rn-realtext" },
			{ ".rte", "x-lml/x-gps" },
			{ ".rtf", "application/rtf" },
			{ ".rtg", "application/metastream" },
			{ ".rtx", "text/richtext" },
			{ ".rv", "video/vnd.rn-realvideo" },
			{ ".rwc", "application/x-rogerwilco" },
			{ ".s3m", "audio/x-mod" },
			{ ".s3z", "audio/x-mod" },
			{ ".sca", "application/x-supercard" },
			{ ".scd", "application/x-msschedule" },
			{ ".sct", "text/scriptlet" },
			{ ".sdf", "application/e-score" },
			{ ".sea", "application/x-stuffit" },
			{ ".setpay", "application/set-payment-initiation" },
			{ ".setreg", "application/set-registration-initiation" },
			{ ".sgm", "text/x-sgml" },
			{ ".sgml", "text/x-sgml" },
			{ ".sh", "application/x-sh" },
			{ ".shar", "application/x-shar" },
			{ ".shtml", "magnus-internal/parsed-html" },
			{ ".shw", "application/presentations" },
			{ ".si6", "image/si6" },
			{ ".si7", "image/vnd.stiwap.sis" },
			{ ".si9", "image/vnd.lgtwap.sis" },
			{ ".sis", "application/vnd.symbian.install" },
			{ ".sit", "application/x-stuffit" },
			{ ".skd", "application/x-Koan" },
			{ ".skm", "application/x-Koan" },
			{ ".skp", "application/x-Koan" },
			{ ".skt", "application/x-Koan" },
			{ ".slc", "application/x-salsa" },
			{ ".smd", "audio/x-smd" },
			{ ".smi", "application/smil" },
			{ ".smil", "application/smil" },
			{ ".smp", "application/studiom" },
			{ ".smz", "audio/x-smd" },
			{ ".snd", "audio/basic" },
			{ ".spc", "application/x-pkcs7-certificates" },
			{ ".spl", "application/futuresplash" },
			{ ".spr", "application/x-sprite" },
			{ ".sprite", "application/x-sprite" },
			{ ".sdp", "application/sdp" },
			{ ".spt", "application/x-spt" },
			{ ".src", "application/x-wais-source" },
			{ ".sst", "application/vnd.ms-pkicertstore" },
			{ ".stk", "application/hyperstudio" },
			{ ".stl", "application/vnd.ms-pkistl" },
			{ ".stm", "text/html" },
			{ ".svg", "image/svg+xml" },
			{ ".sv4cpio", "application/x-sv4cpio" },
			{ ".sv4crc", "application/x-sv4crc" },
			{ ".svf", "image/vnd" },
			{ ".svg", "image/svg+xml" },
			{ ".svh", "image/svh" },
			{ ".svr", "x-world/x-svr" },
			{ ".swf", "application/x-shockwave-flash" },
			{ ".swfl", "application/x-shockwave-flash" },
			{ ".t", "application/x-troff" },
			{ ".tad", "application/octet-stream" },
			{ ".talk", "text/x-speech" },
			{ ".tar", "application/x-tar" },
			{ ".taz", "application/x-tar" },
			{ ".tbp", "application/x-timbuktu" },
			{ ".tbt", "application/x-timbuktu" },
			{ ".tcl", "application/x-tcl" },
			{ ".tex", "application/x-tex" },
			{ ".texi", "application/x-texinfo" },
			{ ".texinfo", "application/x-texinfo" },
			{ ".tgz", "application/x-compressed" },
			{ ".thm", "application/vnd.eri.thm" },
			{ ".tif", "image/tiff" },
			{ ".tiff", "image/tiff" },
			{ ".tki", "application/x-tkined" },
			{ ".tkined", "application/x-tkined" },
			{ ".toc", "application/toc" },
			{ ".toy", "image/toy" },
			{ ".tr", "application/x-troff" },
			{ ".trk", "x-lml/x-gps" },
			{ ".trm", "application/x-msterminal" },
			{ ".tsi", "audio/tsplayer" },
			{ ".tsp", "application/dsptype" },
			{ ".tsv", "text/tab-separated-values" },
			{ ".ttf", "application/octet-stream" },
			{ ".ttz", "application/t-time" },
			{ ".txt", "text/plain" },
			{ ".uls", "text/iuls" },
			{ ".ult", "audio/x-mod" },
			{ ".ustar", "application/x-ustar" },
			{ ".uu", "application/x-uuencode" },
			{ ".uue", "application/x-uuencode" },
			{ ".vcd", "application/x-cdlink" },
			{ ".vcf", "text/x-vcard" },
			{ ".vdo", "video/vdo" },
			{ ".vib", "audio/vib" },
			{ ".viv", "video/vivo" },
			{ ".vivo", "video/vivo" },
			{ ".vmd", "application/vocaltec-media-desc" },
			{ ".vmf", "application/vocaltec-media-file" },
			{ ".vmi", "application/x-dreamcast-vms-info" },
			{ ".vms", "application/x-dreamcast-vms" },
			{ ".vox", "audio/voxware" },
			{ ".vqe", "audio/x-twinvq-plugin" },
			{ ".vqf", "audio/x-twinvq" },
			{ ".vql", "audio/x-twinvq" },
			{ ".vre", "x-world/x-vream" },
			{ ".vrml", "x-world/x-vrml" },
			{ ".vrt", "x-world/x-vrt" },
			{ ".vrw", "x-world/x-vream" },
			{ ".vts", "workbook/formulaone" },
			{ ".wav", "audio/x-wav" },
			{ ".wax", "audio/x-ms-wax" },
			{ ".wbmp", "image/vnd.wap.wbmp" },
			{ ".wcm", "application/vnd.ms-works" },
			{ ".wdb", "application/vnd.ms-works" },
			{ ".web", "application/vnd.xara" },
			{ ".wi", "image/wavelet" },
			{ ".wis", "application/x-InstallShield" },
			{ ".wks", "application/vnd.ms-works" },
			{ ".wm", "video/x-ms-wm" },
			{ ".wma", "audio/x-ms-wma" },
			{ ".wmd", "application/x-ms-wmd" },
			{ ".wmf", "application/x-msmetafile" },
			{ ".wml", "text/vnd.wap.wml" },
			{ ".wmlc", "application/vnd.wap.wmlc" },
			{ ".wmls", "text/vnd.wap.wmlscript" },
			{ ".wmlsc", "application/vnd.wap.wmlscriptc" },
			{ ".wmlscript", "text/vnd.wap.wmlscript" },
			{ ".wmv", "audio/x-ms-wmv" },
			{ ".wmx", "video/x-ms-wmx" },
			{ ".wmz", "application/x-ms-wmz" },
			{ ".wpng", "image/x-up-wpng" },
			{ ".wps", "application/vnd.ms-works" },
			{ ".wpt", "x-lml/x-gps" },
			{ ".wri", "application/x-mswrite" },
			{ ".wrl", "x-world/x-vrml" },
			{ ".wrz", "x-world/x-vrml" },
			{ ".ws", "text/vnd.wap.wmlscript" },
			{ ".wsc", "application/vnd.wap.wmlscriptc" },
			{ ".wv", "video/wavelet" },
			{ ".wvx", "video/x-ms-wvx" },
			{ ".wxl", "application/x-wxl" },
			{ ".x-gzip", "application/x-gzip" },
			{ ".xaf", "x-world/x-vrml" },
			{ ".xar", "application/vnd.xara" },
			{ ".xbm", "image/x-xbitmap" },
			{ ".xdm", "application/x-xdma" },
			{ ".xdma", "application/x-xdma" },
			{ ".xdw", "application/vnd.fujixerox.docuworks" },
			{ ".xht", "application/xhtml+xml" },
			{ ".xhtm", "application/xhtml+xml" },
			{ ".xhtml", "application/xhtml+xml" },
			{ ".xla", "application/vnd.ms-excel" },
			{ ".xlc", "application/vnd.ms-excel" },
			{ ".xll", "application/x-excel" },
			{ ".xlm", "application/vnd.ms-excel" },
			{ ".xls", "application/vnd.ms-excel" },
			{ ".xlsx",
					"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" },
			{ ".xlt", "application/vnd.ms-excel" },
			{ ".xlw", "application/vnd.ms-excel" }, { ".xm", "audio/x-mod" },
			{ ".xml", "text/plain" }, { ".xml", "application/xml" },
			{ ".xmz", "audio/x-mod" }, { ".xof", "x-world/x-vrml" },
			{ ".xpi", "application/x-xpinstall" },
			{ ".xpm", "image/x-xpixmap" }, { ".xsit", "text/xml" },
			{ ".xsl", "text/xml" }, { ".xul", "text/xul" },
			{ ".xwd", "image/x-xwindowdump" }, { ".xyz", "chemical/x-pdb" },
			{ ".yz1", "application/x-yz1" },
			{ ".z", "application/x-compress" },
			{ ".zac", "application/x-zaurus-zac" },
			{ ".zip", "application/zip" }, { ".json", "application/json" } };

	/**
	 * 根据文件后缀名获得对应的MIME类型。
	 * @param file
	 */
	public static String getMIMEType(File file) {
		String type = "*/*";
		String fName = file.getName();
		// 获取后缀名前的分隔符"."在fName中的位置。
		int dotIndex = fName.lastIndexOf(".");
		if (dotIndex < 0) {
			return type;
		}
		/* 获取文件的后缀名 */
		String end = fName.substring(dotIndex, fName.length()).toLowerCase();
		if (end == "")
			return type;
		// 在MIME和文件类型的匹配表中找到对应的MIME类型。
		for (int i = 0; i < MIME_MapTable.length; i++) { 
			if (end.equals(MIME_MapTable[i][0]))
				type = MIME_MapTable[i][1];
		}
		return type;
	}
	public static void main(String[] args) {
		//下面输出为:application/vnd.android.package-archive
		System.out.println(MimeTest.getMIMEType(new File("C:\\oyp.apk")));
	}
}

                         



                            ====================================================================================

  作者:欧阳鹏  欢迎转载,与人分享是进步的源泉!

  转载请保留原文地址http://blog.csdn.net/ouyang_peng

====================================================================================

 


版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
全方位解读服务网格(Service Mesh)的背景和概念
为了解决微服务框架的侵入性问题,我们引入服务网格。
1243 0
PolarDB 并行查询的前世今生
本文会深入介绍PolarDB MySQL在并行查询这一企业级查询加速特性上做的技术探索、形态演进和相关组件的实现原理,所涉及功能随PolarDB MySQL 8.0.2版本上线。
507 0
企业内部应用接入钉钉获取部门及人员信息
企业内部应用接入钉钉,同时通过API获取当前企业下部门及人员信息
1189 0
MySQL模糊查询再也用不着 like+% 了!
我们都知道 InnoDB 在模糊查询数据时使用 "%xx" 会导致索引失效,但有时需求就是如此,类似这样的需求还有很多,例如,搜索引擎需要根基用户数据的关键字进行全文查找,电子商务网站需要根据用户的查询条件,在可能需要在商品的详细介绍中进行查找,这些都不是B+树索引能很好完成的工作。 通过数值比较,范围过滤等就可以完成绝大多数我们需要的查询了。但是,如果希望通过关键字的匹配来进行查询过滤,那么就需要基于相似度的查询,而不是原来的精确数值比较,全文索引就是为这种场景设计的。
25671 0
阿里云云原生一体化数仓正式发布  助力企业数据驱动业务创新
云原生一体化数仓是集阿里云大数据产品MaxCompute、DataWorks、Hologres三种产品能力于一体的一站式大数据处理平台。核心是3个一体化和全链路数据治理能力,包括离线实时一体、湖仓一体、分析服务一体、全链路数据治理。
1611 0
全面公测|Grafana服务:一张图表胜过千行指标&日志
Grafana 帮助运维人员轻松处理各类运维过程中遇到的各类数据可视化与分析难题。目前阿里云 Grafana 服务全面免费公测,帮助企业轻松构建运维数据可视化平台,轻松实现数据驱动运维!
1160 0
一起学Golang系列(五)初次接触Go语言可能遇到的各种坑!
前面介绍了Go语言的基础语法,所谓磨刀不误砍柴工,希望大家还是能熟悉掌握这些基础知识,这样后面真正学起Go来才会得心应手。 作为初学者。Go语言的语法有些和java类似,但也有很多不一样的地方。刚开始都会遇到各种各样的坑。下面就来总结下学习go语言的过程中,遇到的各种坑。
1034 0
设备接入--海康摄像头SDK
springboot-对接海康摄像头,兼容window和Linux环境
1343 0
Flink SQL 在快手的扩展和实践
快手实时计算团队技术专家张静、张芒在 FFA 2021 的分享
1147 0
无影云桌面,企业与个人的应用神器
阿里云无影云桌面( Elastic Desktop Service)的原产品名为弹性云桌面,融合了无影产品技术后更名升级。它可以为您提供易用、安全、高效的云上桌面服务,帮助您快速构建、高效管理桌面办公环境,提供安全、灵活的办公体系。
276298 0
+关注
欧阳鹏
一个人,如果你不逼自己一把,你根本不知道自己有多优秀! Talk is cheap, show me the code.
473
文章
0
问答
文章排行榜
最热
最新
相关电子书
更多
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
冬季实战营第三期:MySQL数据库进阶实战
立即下载