public String fileMIMEType(String substring){
if (substring.equals(".GIF") || substring.equals(".gif") || substring.toUpperCase().equals(".GIF")) {
return "image/gif";
} else if(substring.equals(".BMP") || substring.equals(".bmp") || substring.toUpperCase().equals(".BMP")) {
return "image/bmp";
} else if (substring.equals(".JPEG") || substring.equals(".jpeg") || substring.equals(".JPG")
|| substring.equals(".jpg") || substring.equals(".PNG")
|| substring.equals(".png") || substring.toUpperCase().equals(".JPEG")
|| substring.toUpperCase().equals(".JPG") || substring.toUpperCase().equals(".PNG")) {
return "image/jpeg";
} else if (substring.equals(".HTML") || substring.equals(".html")) {
return "text/html";
} else if (substring.equals(".TXT") || substring.equals(".txt") || substring.toUpperCase().equals(".TXT")){
return "text/plain";
} else if (substring.equals(".VSD") || substring.equals(".vsd") || substring.toUpperCase().equals(".VSD")){
return "application/vnd.visio";
} else if (substring.equals(".PPTX") || substring.equals(".pptx") || substring.equals(".PPT")
|| substring.equals(".ppt") || substring.toUpperCase().equals(".PPTX")
|| substring.toUpperCase().equals(".PPT")){
return "application/vnd.ms-powerpoint";
} else if(substring.equals(".DOCX") || substring.equals(".docx") || substring.equals(".DOC")
|| substring.equals(".doc") || substring.toUpperCase().equals(".DOCX")
|| substring.toUpperCase().equals(".DOC")){
return "application/msword";
} else if(substring.equals(".XML") || substring.equals(".xml") || substring.toUpperCase().equals(".XML")){
return "text/xml";
} else if(substring.equals(".pdf") || substring.equals(".PDF") || substring.toUpperCase().equals(".PDF")){
return "application/pdf";
} else {
return null;
}
}
int indexOf = fileName.lastIndexOf(".");
if (indexOf > 0) {
String substring = fileName.substring(indexOf);
System.out.println("substring===================="+substring);
jsonObject.put("file_type", fileMIMEType(substring));
}
mikuriya,偶遇良缘。