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

MimeTypecopyMimeType(final MimeType original)
copy Mime Type
return new MimeType(original.getPrimaryType(), original.getSubType());
MimeTypecreateWildcard()
create Wildcard
try {
    return new MimeType("*/*");
} catch (Exception e) {
    return null; 
booleanequal(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);
StringgetContentType(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";
...
StringgetContentType(String filePath)
Returns the mime type of the given file.
FileTypeMap map = MimetypesFileTypeMap.getDefaultFileTypeMap();
return map.getContentType(filePath);
StringgetContentTypeFromFileName(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);
...
StringgetMimeType(final String filename)
get Mime Type
if (filename == null) {
    return null;
return mimeMap.getContentType(filename);
StringgetMimetype(String filename)
get Mimetype
return mimeMap.getContentType(filename);
StringgetMimeTypeForFileName(String filename)
get Mime Type For File Name
String mimeType = mimeTypes.getContentType(filename);
if (mimeType != null) {
    return mimeType;
} else {
    return GENERIC_MIME_TYPE;
voidinit()
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");
...