MIMETypeUtil
org.clapper.util.misc

Class MIMETypeUtil



  • public class MIMETypeUtilextends Object
    The MIMETypeUtil class provides some general purpose MIME type utilities not found in the JDK. Among other methods, this class provides the fileExtensionForMIMEType() method, which converts a MIME type to a file extension. That method uses a traditional mime.types files, similar to the file shipped with with web servers such as Apache. It looks for a suitable file in the following locations:
    1. First, it looks for the file .mime.types in the user's home directory.
    2. Next, it looks for mime.types (no leading ".") in all the directories in the CLASSPATH
    3. Last, it loads a default set of mappings shipped with this library

    It loads all the matching files it finds; the first mapping found for a given MIME type is the one that is used. The files are only loaded once within a given running Java VM.

    The syntax of the file follows the classic mime.types syntax:

     # The format is <mime type> <space separated file extensions> # Comments begin with a '#' text/plain             txt text TXT text/html              html htm HTML HTM ... 

    When mapping a MIME type to an extension, fileExtensionForMIMEType() uses the first extension it finds in the mime.types file. MIME types that cannot be found in the file are mapped to extension ".dat".

SCaVis 2.1 © jWork.ORG