List of utility methods to do Activation Mimetype Check
MimeType | copyMimeType(final MimeType original) copy Mime Type return new MimeType(original.getPrimaryType(), original.getSubType()); |
MimeType | createWildcard() create Wildcard try { return new MimeType("*/*"); } catch (Exception e) { return null; |
boolean | equal(String string1, String string2) Returns true if the given MIME type strings are considered equivalent because their types and subtypes match (parameters are not considered in the comparison). if (string1 == null && string2 == null) return true; if (string1 == null || string2 == null) return false; MimeType mimeType1 = new MimeType(string1); MimeType mimeType2 = new MimeType(string2); return mimeType1.match(mimeType2); |
String | getContentType(String filename) get Content Type if (filename == null || filename.length() == 0) { return "application/octet-stream"; String contentType; if (filename.endsWith(".html") || filename.endsWith(".htm")) { contentType = "text/html"; } else if (filename.endsWith(".js")) { contentType = "text/javascript"; ... |
String | getContentType(String filePath) Returns the mime type of the given file. FileTypeMap map = MimetypesFileTypeMap.getDefaultFileTypeMap();
return map.getContentType(filePath);
|
String | getContentTypeFromFileName(String fileName) get Content Type From File Name FileTypeMap map = FileTypeMap.getDefaultFileTypeMap(); if (map instanceof MimetypesFileTypeMap) { try { ((MimetypesFileTypeMap) map).addMimeTypes("image/png png PNG"); } catch (Exception ignored) { return map.getContentType(fileName); ... |
String | getMimeType(final String filename) get Mime Type if (filename == null) { return null; return mimeMap.getContentType(filename); |
String | getMimetype(String filename) get Mimetype return mimeMap.getContentType(filename);
|
String | getMimeTypeForFileName(String filename) get Mime Type For File Name String mimeType = mimeTypes.getContentType(filename); if (mimeType != null) { return mimeType; } else { return GENERIC_MIME_TYPE; |
void | init() Init the mime type list mimeTypes.addMimeTypes("application/vnd.ms-excel xls xlt"); mimeTypes.addMimeTypes("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx"); mimeTypes.addMimeTypes("application/msword doc dot"); mimeTypes.addMimeTypes("application/vnd.openxmlformats-officedocument.wordprocessingml.document docx"); mimeTypes.addMimeTypes("application/pdf pdf"); mimeTypes.addMimeTypes("application/rtf rtf"); mimeTypes.addMimeTypes("text/csv csv"); mimeTypes.addMimeTypes("application/vnd.ms-powerpoint ppt pps pot"); ... |