Java Utililty Methods Activation Mimetype Check

List of utility methods to do Activation Mimetype Check

Description

The list of methods to do Activation Mimetype Check are organized into topic(s).

Method

voidinitFileTypeMap()
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");
...
booleanisFileImage(String fileName)
is File Image
String mimetype = mtftp.getContentType(fileName);
String type = mimetype.split("/")[0];
return type.equals("image");
booleanisImage(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;
...
booleanisMimeType(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;
...
BooleanisValidateContentType(String contentType)
Validate the given Content-Type.
try {
    new MimeType(contentType);
} catch (MimeTypeParseException e) {
    return false;
return true;
voidsetMinetypes()
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");
...