Top Description Fields Constructors Methods
jakarta.activation

public abstract Class FileTypeMap

extends Object
Class Inheritance
Known Direct Subclasses
jakarta.activation.MimetypesFileTypeMap
Imports
java.io.File, java.util.Map, .WeakHashMap

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
jakarta.activation.FileTypeMap, jakarta.activation.FileDataSource, jakarta.activation.MimetypesFileTypeMap

Field Summary

Modifier and TypeField and Description
private static FileTypeMap
private static Map<ClassLoader, FileTypeMap>

Constructor Summary

AccessConstructor and Description
public
FileTypeMap()

The default constructor.

Method Summary

Modifier and TypeMethod and Description
public abstract String

Returns:

The content type.
getContentType
(File
A file to be typed.
file
)

Return the type of the file object.

public abstract String

Returns:

The content type.
getContentType
(String
the pathname of the file.
filename
)

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

public static synchronized FileTypeMap

Returns:

The default FileTypeMap
getDefaultFileTypeMap
()

Return the default FileTypeMap for the system.

public static synchronized void
setDefaultFileTypeMap(FileTypeMap
The FileTypeMap.
fileTypeMap
)

Sets the default FileTypeMap for the system.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultMapback to summary
private static FileTypeMap defaultMap
mapback to summary
private static Map<ClassLoader, FileTypeMap> map

Constructor Detail

FileTypeMapback to summary
public FileTypeMap()

The default constructor.

Method Detail

getContentTypeback to summary
public abstract String getContentType(File file)

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

Parameters
file:File

A file to be typed.

Returns:String

The content type.

getContentTypeback to summary
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:String

the pathname of the file.

Returns:String

The content type.

getDefaultFileTypeMapback to summary
public static synchronized FileTypeMap getDefaultFileTypeMap()

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

Returns:FileTypeMap

The default FileTypeMap

See Also
jakarta.activation.FileTypeMap#setDefaultFileTypeMap
setDefaultFileTypeMapback to summary
public static synchronized void setDefaultFileTypeMap(FileTypeMap fileTypeMap)

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

Parameters
fileTypeMap:FileTypeMap

The FileTypeMap.

Exceptions
SecurityException:
if the caller doesn't have permission to change the default