class MimeTypes extends Object
Supports mime types only, not encodings. Does not support a default "*" mapping.
This is only for local mappings. Caller should use getServletContext().getMimeType() if this returns null.
| Constructor and Description |
|---|
MimeTypes() |
| Modifier and Type | Method and Description |
|---|---|
void | addMimeMapping(String extension,
String type)Set a mime mapping. |
String | getMimeByExtension(String filename)Get the MIME type by filename extension. |
void | loadMimeMap(String resourcePath)Load MIME type mappings from a resource file. |
public void addMimeMapping(String extension, String type)
extension - the file extension (without the dot), case-insensitivetype - the MIME type to associate with the extensionpublic String getMimeByExtension(String filename)
Returns ONLY local mappings. Caller should use getServletContext().getMimeType() if this returns null.
filename - A file namepublic void loadMimeMap(String resourcePath)
resourcePath - the resource path in the classpath, without ".properties" extension