public abstract class FileTypeMap extends Object
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.
FileTypeMap
, FileDataSource
, MimetypesFileTypeMap
public FileTypeMap()
The default constructor.
public abstract String getContentType(File file)
Return the type of the file object. This method should always return a valid MIME type.
file
- A file to be typed.public abstract String getContentType(String filename)
Return the type of the file passed in. This method should always return a valid MIME type.
filename
- the pathname of the file.public static void setDefaultFileTypeMap(FileTypeMap fileTypeMap)
Sets the default FileTypeMap for the system. This instance will be returned to callers of getDefaultFileTypeMap.
fileTypeMap
- The FileTypeMap.SecurityException
- if the caller doesn't have permission to change the defaultpublic static FileTypeMap getDefaultFileTypeMap()
Return the default FileTypeMap for the system. If setDefaultFileTypeMap was called, return that instance, otherwise return an instance of MimetypesFileTypeMap
.
setDefaultFileTypeMap(javax.activation.FileTypeMap)
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.