Top Fields Constructors Methods
org.jruby.util

public final Class RubyFileTypeDetector

extends FileTypeDetector
Class Inheritance
Imports
java.io.BufferedReader, .IOException, java.nio.charset.StandardCharsets, java.nio.file.Files, .Path, java.nio.file.spi.FileTypeDetector, java.util.Locale, java.util.regex.Pattern

Field Summary

Modifier and TypeField and Description
private static final String[]
private static final String[]
private static final String
private static final Pattern

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
probeContentType(Path
the path to the file to probe
path
)

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

Probes the given file to guess its content type.

Field Detail

KNOWN_RUBY_FILESback to summary
private static final String[] KNOWN_RUBY_FILES
KNOWN_RUBY_SUFFIXESback to summary
private static final String[] KNOWN_RUBY_SUFFIXES
RUBY_MIMEback to summary
private static final String RUBY_MIME
SHEBANG_REGEXPback to summary
private static final Pattern SHEBANG_REGEXP

Constructor Detail

RubyFileTypeDetectorback to summary
public RubyFileTypeDetector()

Method Detail

probeContentTypeback to summary
public String probeContentType(Path path) throws IOException

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

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

Probes the given file to guess its content type.

The means by which this method determines the file type is highly implementation specific. It may simply examine the file name, it may use a file attribute, or it may examine bytes in the file.

The probe result is the string form of the value of a Multipurpose Internet Mail Extension (MIME) content type as defined by RFC 2045: Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies. The string must be parsable according to the grammar in the RFC 2045.

Parameters
path:Path

the path to the file to probe

Returns:String

The content type or null if the file type is not recognized

Annotations
@Override
Exceptions
IOException:
An I/O error occurs