List of utility methods to do Activation Mimetype Check
void | initFileTypeMap() init File Type Map fileTypeMap = new MimetypesFileTypeMap(); fileTypeMap.addMimeTypes("application/atom+xml atom"); fileTypeMap.addMimeTypes("application/msword doc dot"); fileTypeMap.addMimeTypes("application/mspowerpoint ppt pot"); fileTypeMap.addMimeTypes("application/msexcel xls"); fileTypeMap.addMimeTypes("application/pdf pdf"); fileTypeMap.addMimeTypes("application/rdf+xml rdf rss"); fileTypeMap.addMimeTypes("application/x-vnd.openxmlformat docx docm dotx dotm"); ... |
boolean | isFileImage(String fileName) is File Image String mimetype = mtftp.getContentType(fileName); String type = mimetype.split("/")[0]; return type.equals("image"); |
boolean | isImage(String fileName, boolean output) Obtains a files MIME type and returns true if it is of type image MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap(); String mimeType = mimeTypesMap.getContentType(fileName); if (output) { System.out.println("Validating input file..."); System.out.println("File type: " + mimeType); if (mimeType.startsWith("image")) { return true; ... |
boolean | isMimeType(String a) Returns true if this is a valid media type boolean answer = false; try { new MimeType(a); answer = true; } catch (javax.activation.MimeTypeParseException e) { answer = false; return answer; ... |
Boolean | isValidateContentType(String contentType) Validate the given Content-Type. try { new MimeType(contentType); } catch (MimeTypeParseException e) { return false; return true; |
void | setMinetypes() set Minetypes mimeTypeMap.addMimeTypes("text/plain txt"); mimeTypeMap.addMimeTypes("text/html html htm xhtml"); mimeTypeMap.addMimeTypes("text/javascript js"); mimeTypeMap.addMimeTypes("text/css css"); mimeTypeMap.addMimeTypes("image/png png"); mimeTypeMap.addMimeTypes("image/jpeg jpeg"); mimeTypeMap.addMimeTypes("image/jpeg jpg"); mimeTypeMap.addMimeTypes("image/gif gif"); ... |