javax.activation
Class MimetypesFileTypeMap
public class MimetypesFileTypeMap
Implementation of FileTypeMap that uses the
mime.types format.
File entries are searched for in the following locations and order:
- Programmatically added entries to this instance
- The file .mime.types in the user's home directory
- The file <java.home>/lib/mime.types
- The resource META-INF/mime.types
- The resource META-INF/mimetypes.default in the JAF
distribution
void | addMimeTypes(String mime_types) - Adds entries prorammatically to the registry.
|
String | getContentType(File f) - Returns the MIME content type of the file.
|
String | getContentType(String filename) - Returns the MIME type based on the given filename.
|
MimetypesFileTypeMap
public MimetypesFileTypeMap()
Default constructor.
MimetypesFileTypeMap
public MimetypesFileTypeMap(InputStream is)
Constructor specifying an input stream.
is
- the input stream to read mime.types entries from
MimetypesFileTypeMap
public MimetypesFileTypeMap(String mimeTypeFileName)
throws IOException
Constructor specifying a filename.
mimeTypeFileName
- the name of the file to read mime.types
entries from
addMimeTypes
public void addMimeTypes(String mime_types)
Adds entries prorammatically to the registry.
mime_types
- a mime.types formatted entries string
getContentType
public String getContentType(File f)
Returns the MIME content type of the file.
This calls getContentType(f.getName())
.
- getContentType in interface FileTypeMap
f
- the file
getContentType
public String getContentType(String filename)
Returns the MIME type based on the given filename.
If no entry is found, returns "application/octet-stream".
- getContentType in interface FileTypeMap
filename
- the filename