APIdia Launch Partner
Top Description Fields Constructors Methods
sun.nio.fs

pack-priv Class MimeTypesFileTypeDetector

extends AbstractFileTypeDetector
Class Inheritance
Imports
java.io.IOException, java.nio.charset.Charset, java.nio.file.Files, .Path, java.util.Collections, .HashMap, .List, .Map, java.util.regex.Matcher, .Pattern

File type detector that uses a file extension to look up its MIME type based on a mime.types file.

Field Summary

Modifier and TypeField and Description
private volatile boolean
private Map<String, String>
private final Path

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected String
implProbeContentType(Path path)

Implements abstract sun.nio.fs.AbstractFileTypeDetector.implProbeContentType.

Probes the given file to guess its content type.

private void
loadMimeTypes()

Parse the mime types file, and store the type-extension mappings into mimeTypeMap.

private void
parseMimeEntry(String entry)

Parse a mime-types entry, which can have the following formats.

private void
Inherited from sun.nio.fs.AbstractFileTypeDetector:
getExtensionprobeContentType

Field Detail

loadedback to summary
private volatile boolean loaded
mimeTypeMapback to summary
private Map<String, String> mimeTypeMap
mimeTypesFileback to summary
private final Path mimeTypesFile

Constructor Detail

MimeTypesFileTypeDetectorback to summary
public MimeTypesFileTypeDetector(Path filePath)

Method Detail

implProbeContentTypeback to summary
protected String implProbeContentType(Path path)

Implements abstract sun.nio.fs.AbstractFileTypeDetector.implProbeContentType.

Doc from sun.nio.fs.AbstractFileTypeDetector.implProbeContentType.

Probes the given file to guess its content type.

Annotations
@Override
loadMimeTypesback to summary
private void loadMimeTypes()

Parse the mime types file, and store the type-extension mappings into mimeTypeMap. The mime types file is not loaded until the first probe to achieve the lazy initialization. It adopts double-checked locking optimization to reduce the locking overhead.

parseMimeEntryback to summary
private void parseMimeEntry(String entry)

Parse a mime-types entry, which can have the following formats. 1) Simple space-delimited format image/jpeg jpeg jpg jpe JPG 2) Netscape key-value pair format type=application/x-java-jnlp-file desc="Java Web Start" exts="jnlp" or type=text/html exts=htm,html

putIfAbsentback to summary
private void putIfAbsent(String key, String value)