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

public abstract Class AbstractFileTypeDetector

extends FileTypeDetector
Class Inheritance
Known Direct Subclasses
sun.nio.fs.MimeTypesFileTypeDetector
Imports
java.net.FileNameMap, .URLConnection, java.nio.file.Path, java.nio.file.spi.FileTypeDetector, java.util.Locale, java.io.IOException

Base implementation of FileTypeDetector

Field Summary

Modifier and TypeField and Description
private static final String
TSPECIALS

Special characters

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected final String

Returns:

The characters after the first dot or an empty string.
getExtension
(String
A file name
name
)

Returns the extension of a file name, specifically the portion of the parameter string after the first dot.

protected abstract String
implProbeContentType(Path file)

Probes the given file to guess its content type.

private static boolean
isTokenChar(char c)

Returns true if the character is a valid token character.

private static boolean
isValidToken(String s)

Returns true if the given string is a legal type or subtype.

private static String
parse(String s)

Parses a candidate content type into its type and subtype, returning null if either token is invalid.

public final String
probeContentType(Path file)

Implements abstract java.nio.file.spi.FileTypeDetector.probeContentType.

Invokes the appropriate probe method to guess a file's content type, and checks that the content type's syntax is valid.

Field Detail

TSPECIALSback to summary
private static final String TSPECIALS

Special characters

Constructor Detail

AbstractFileTypeDetectorback to summary
protected AbstractFileTypeDetector()

Method Detail

getExtensionback to summary
protected final String getExtension(String name)

Returns the extension of a file name, specifically the portion of the parameter string after the first dot. If the parameter is null, empty, does not contain a dot, or the dot is the last character, then an empty string is returned, otherwise the characters after the dot are returned.

Parameters
name:String

A file name

Returns:String

The characters after the first dot or an empty string.

implProbeContentTypeback to summary
protected abstract String implProbeContentType(Path file) throws IOException

Probes the given file to guess its content type.

isTokenCharback to summary
private static boolean isTokenChar(char c)

Returns true if the character is a valid token character.

isValidTokenback to summary
private static boolean isValidToken(String s)

Returns true if the given string is a legal type or subtype.

parseback to summary
private static String parse(String s)

Parses a candidate content type into its type and subtype, returning null if either token is invalid.

probeContentTypeback to summary
public final String probeContentType(Path file) throws IOException

Implements abstract java.nio.file.spi.FileTypeDetector.probeContentType.

Invokes the appropriate probe method to guess a file's content type, and checks that the content type's syntax is valid.

Annotations
@Override
Exceptions
IOException:

Doc from java.nio.file.spi.FileTypeDetector.probeContentType.

An I/O error occurs