public abstract class

FileTypeMap

extends Object
java.lang.Object
   ↳ com.google.code.javax.activation.FileTypeMap
Known Direct Subclasses

Class Overview

The FileTypeMap is an abstract class that provides a data typing interface for files. Implementations of this class will implement the getContentType methods which will derive a content type from a file name or a File object. FileTypeMaps could use any scheme to determine the data type, from examining the file extension of a file (like the MimetypesFileTypeMap) to opening the file and trying to derive its type from the contents of the file. The FileDataSource class uses the default FileTypeMap (a MimetypesFileTypeMap unless changed) to determine the content type of files.

See Also
  • javax.activation.FileTypeMap
  • javax.activation.FileDataSource
  • javax.activation.MimetypesFileTypeMap

Summary

Fields
private static FileTypeMap defaultMap
Public Constructors
FileTypeMap()
The default constructor.
Public Methods
abstract String getContentType(File file)
Return the type of the file object.
abstract String getContentType(String filename)
Return the type of the file passed in.
static FileTypeMap getDefaultFileTypeMap()
Return the default FileTypeMap for the system.
static void setDefaultFileTypeMap(FileTypeMap map)
Sets the default FileTypeMap for the system.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private static FileTypeMap defaultMap

Public Constructors

public FileTypeMap ()

The default constructor.

Public Methods

public abstract String getContentType (File file)

Return the type of the file object. This method should always return a valid MIME type.

Parameters
file A file to be typed.
Returns
  • The content type.

public abstract String getContentType (String filename)

Return the type of the file passed in. This method should always return a valid MIME type.

Parameters
filename The pathname of the file.
Returns
  • The content type.

public static FileTypeMap getDefaultFileTypeMap ()

Return the default FileTypeMap for the system. If setDefaultFileTypeMap was called, return that instance, otherwise return an instance of MimetypesFileTypeMap.

Returns
  • The default FileTypeMap

public static void setDefaultFileTypeMap (FileTypeMap map)

Sets the default FileTypeMap for the system. This instance will be returned to callers of getDefaultFileTypeMap.

Parameters
map The FileTypeMap.
Throws
SecurityException if the caller doesn't have permission to change the default