: Class MimetypesFileTypeMap

Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.activation
Class MimetypesFileTypeMap

    java.lang.Object
      |
      +--javax.activation.FileTypeMap
            |
            +--javax.activation.MimetypesFileTypeMap

public class MimetypesFileTypeMap
extends FileTypeMap

MimetypesFileTypeMap is the default data typing engine of files for the activation framework. The engine maps filename extensions to data types using the mime.type file format. The registry is constructed from a number of `mime.type` files from various locations, as well as, programmically from data streams and API calls.

#### MIME Type registry file locations

The following files make up the default MIME Type registry:

- user's home/.mime.types
- java.home/lib/mime.types

and if the application is stored in a jar file:

- /META-INF/mime.types
- /META-INF/mimetypes.default

#### Command line testing

This class has a `main` method so it's possible to test some of the funtionality. Supply a content type on the command line to find all the matching extensions in the (automatically constructed) database.

Version:
  $Revision: 1.9 $
Author:
  Andrew Selkirk, Nic Ferrier

Constructor Summary
`MimetypesFileTypeMap()` Create a default MIME Types registry.
`MimetypesFileTypeMap(java.io.InputStream stream)` Create a MIME Types registry with further entries loaded from the specified input stream.
`MimetypesFileTypeMap(java.lang.String filename)` Create a MIME Types registry with further entries loaded from the specified file

Method Summary
`void` | `addMimeTypes(java.lang.String mimeTypes)` Add MIME Type entries to the programmic registry.
`java.lang.String` | `getContentType(java.io.File file)` Get the content type of the specified file.
`java.lang.String` | `getContentType(java.lang.String filename)` Get the content type of the specified file.
`static void` | `main(java.lang.String[] argv)` Takes a content type and finds all the extensions associated with it.

Methods inherited from class javax.activation.FileTypeMap
`getDefaultFileTypeMap, setDefaultFileTypeMap`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MimetypesFileTypeMap

    public MimetypesFileTypeMap()

  Create a default MIME Types registry.

### MimetypesFileTypeMap

    public MimetypesFileTypeMap(java.io.InputStream stream)

  Create a MIME Types registry with further entries loaded from the specified input stream.
  Parameters:
    `stream` - MIME Types formatted data stream

### MimetypesFileTypeMap

    public MimetypesFileTypeMap(java.lang.String filename)
                         throws java.io.IOException

  Create a MIME Types registry with further entries loaded from the specified file
  Parameters:
    `mimeTypeFileName` - MIME Types formatted file
  Throws:
    `java.io.IOException` - IO problem occurred loading the file

Method Detail

### getContentType

    public java.lang.String getContentType(java.io.File file)

  Get the content type of the specified file.
  Overrides:
    `getContentType` in class `FileTypeMap`
  Parameters:
    `file` - File to check
  Returns:
    MIME Type of the file
  See Also:
    `which is called with the file's name`

### getContentType

    public java.lang.String getContentType(java.lang.String filename)

  Get the content type of the specified file. Each of the registries are successively checked to locate a matching file extension to MIME Type content type. The default MIME type is returned if the extension is not located.
  Overrides:
    `getContentType` in class `FileTypeMap`
  Parameters:
    `filename` - name to check
  Returns:
    MIME Type of the file

### addMimeTypes

    public void addMimeTypes(java.lang.String mimeTypes)

  Add MIME Type entries to the programmic registry. The string must be a properly formatted MIME type file entry.
  Parameters:
    `mimeTypes` - MIME Types formatted entry

### main

    public static void main(java.lang.String[] argv)

  Takes a content type and finds all the extensions associated with it. All the extensions are printed out, one per line.
  Parameters:
    `argv` - Command-line arguments

Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

© Copyright 2002 the Free Software Foundation, all rights reserved.