Class javax.activation.MimetypesFileTypeMap
java.lang.Object
|
+----javax.activation.FileTypeMap
|
+----javax.activation.MimetypesFileTypeMap
- public class MimetypesFileTypeMap
- extends FileTypeMap
This class extends FileTypeMap and provides data typing of files
via their file extension. It uses the .mime.types format:
# comments begin with a '#'
# the format is <mime type> <space separated file extensions>
# for example:
text/plain txt text TXT
# this would map file.txt, file.text, and file.TXT to
# the mime type "text/plain"
When either of the getContentType
methods are
called, first the mime type entries added to this instance of
file map are checked, if no mapping it found, the default
entries which are included as part of the JavaBeans Activation
Framework are checked. If no mapping is found, the type
"application/octet-stream" is returned.
Constructor Summary
|
MimetypesFileTypeMap()
The default constructor.
|
MimetypesFileTypeMap(java.lang.String mimeTypeFileName)
Constructor specifies a mimetypes file to
append to the registry.
|
MimetypesFileTypeMap(java.io.InputStream is)
Constructor specifies a mimetypes file
as an InputStream to append to the registry.
|
Method Summary
|
void
|
addMimeTypes(java.lang.String mime_types)
This method prepends the .mimetype values to the
registry.
|
java.lang.String
|
getContentType(java.io.File f)
Return the type of the file object.
|
java.lang.String
|
getContentType(java.lang.String filename)
Return the type of the file passed in
|
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MimetypesFileTypeMap
public MimetypesFileTypeMap()
- The default constructor.
MimetypesFileTypeMap
public MimetypesFileTypeMap(java.lang.String mimeTypeFileName) throws java.io.IOException
- Constructor specifies a mimetypes file to
append to the registry.
MimetypesFileTypeMap
public MimetypesFileTypeMap(java.io.InputStream is)
- Constructor specifies a mimetypes file
as an InputStream to append to the registry.
addMimeTypes
public void addMimeTypes(java.lang.String mime_types)
- This method prepends the .mimetype values to the
registry.
- Parameters:
mime_types
- A .mime.types formatted string of entries.
getContentType
public java.lang.String getContentType(java.io.File f)
- Return the type of the file object.
- Overrides:
- getContentType in class FileTypeMap
getContentType
public java.lang.String getContentType(java.lang.String filename)
- Return the type of the file passed in
- Overrides:
- getContentType in class FileTypeMap