IT. Expert System.

Java Enterprise Edition (EE)

MimetypesFileTypeMap


javax.activation
Class MimetypesFileTypeMap

java.lang.Object
  javax.activation.FileTypeMap
      javax.activation.MimetypesFileTypeMap
public class MimetypesFileTypeMap
extends FileTypeMap

This class extends FileTypeMap and provides data typing of files via their file extension. It uses the .mime.types format.

MIME types file search order:

The MimetypesFileTypeMap looks in various places in the user's system for MIME types file entries. When requests are made to search for MIME types in the MimetypesFileTypeMap, it searches MIME types files in the following order:

  1. Programmatically added entries to the MimetypesFileTypeMap instance.
  2. The file .mime.types in the user's home directory.
  3. The file <java.home>/lib/mime.types.
  4. The file or resources named META-INF/mime.types.
  5. The file or resource named META-INF/mimetypes.default (usually found only in the activation.jar file).

MIME types file format:

# comments begin with a '#'
# the format is <mime type> <space separated file extensions>
# for example:
text/plain txt text TXT
# this would map file.txt, file.text, and file.TXT to
# the mime type "text/plain"

Author:
Bart Calder, Bill Shannon

Constructor Summary
MimetypesFileTypeMap()
          The default constructor.
MimetypesFileTypeMap(java.io.InputStream is)
          Construct a MimetypesFileTypeMap with programmatic entries added from the InputStream.
MimetypesFileTypeMap(java.lang.String mimeTypeFileName)
          Construct a MimetypesFileTypeMap with programmatic entries added from the named file.
 
Method Summary
 void addMimeTypes(java.lang.String mime_types)
          Prepend the MIME type values to the registry.
 java.lang.String getContentType(java.io.File f)
          Return the MIME type of the file object.
 java.lang.String getContentType(java.lang.String filename)
          Return the MIME type based on the specified file name.
 
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()
The default constructor.

MimetypesFileTypeMap

public MimetypesFileTypeMap(java.lang.String mimeTypeFileName)
                     throws java.io.IOException
Construct a MimetypesFileTypeMap with programmatic entries added from the named file.

Parameters:
mimeTypeFileName - the file name
Throws:
java.io.IOException

MimetypesFileTypeMap

public MimetypesFileTypeMap(java.io.InputStream is)
Construct a MimetypesFileTypeMap with programmatic entries added from the InputStream.

Parameters:
is - the input stream to read from
Method Detail

addMimeTypes

public void addMimeTypes(java.lang.String mime_types)
Prepend the MIME type values to the registry.

Parameters:
mime_types - A .mime.types formatted string of entries.

getContentType

public java.lang.String getContentType(java.io.File f)
Return the MIME type of the file object. The implementation in this class calls getContentType(f.getName()).

Specified by:
getContentType in class FileTypeMap
Parameters:
f - the file
Returns:
the file's MIME type

getContentType

public java.lang.String getContentType(java.lang.String filename)
Return the MIME type based on the specified file name. The MIME type entries are searched as described above under MIME types file search order. If no entry is found, the type "application/octet-stream" is returned.

Specified by:
getContentType in class FileTypeMap
Parameters:
filename - the file name
Returns:
the file's MIME type


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 1222 / 248361828. Delta: 0.02907 с