forked from kaka2008/useful-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMimeUtils.java
More file actions
58 lines (54 loc) · 1.62 KB
/
MimeUtils.java
File metadata and controls
58 lines (54 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* ¸ù¾ÝÎļþºó׺À´µÃµ½mime type
*
* @author kaka2008
*
*/
public class MimeUtils {
/**
*
*/
public MimeUtils() {
super();
}
public static String getMIMETypeByExtName(String filePro) {
String mimeType = "text/plain";
if (filePro == null)
return mimeType;
if (filePro.toLowerCase().equals("doc")) {
mimeType = "application/msword";
} else if (filePro.toLowerCase().equals("ppt")) {
mimeType = "application/mspowerpoint";
} else if (filePro.toLowerCase().equals("xls")) {
mimeType = "application/msexcel";
} else if (filePro.toLowerCase().equals("vsd")) {
mimeType = "application/msvisio";
} else if (filePro.toLowerCase().equals("pdf")) {
mimeType = "application/pdf";
} else if (filePro.toLowerCase().equals("zip")) {
mimeType = "application/zip";
} else if ((filePro.toLowerCase().equals("jpg"))
| (filePro.toLowerCase().equals("jpeg"))) {
mimeType = "image/jpeg";
} else if (filePro.toLowerCase().equals("gif")) {
mimeType = "image/gif";
} else if (filePro.toLowerCase().equals("tif")) {
mimeType = "image/tiff";
} else if (filePro.toLowerCase().equals("png")) {
mimeType = "image/png";
} else if (filePro.toLowerCase().equals("txt")) {
mimeType = "text/plain";
} else if (filePro.toLowerCase().equals("rtf")) {
mimeType = "text/rtf";
} else if (filePro.toLowerCase().equals("html")) {
mimeType = "text/html";
} else if (filePro.toLowerCase().equals("xml")) {
mimeType = "text/xml";
} else if (filePro.toLowerCase().equals("swf")) {
mimeType = "application/x-shockwave-flash";
} else {
mimeType = "text/plain";
}
return mimeType;
}
}