public static interface TruffleFile.FileTypeDetector
file's MIME type and encoding.
The means by which the detector determines the MIME is highly implementation specific. A
simple implementation might detect the MIME type using file extension. In
other cases, the content of file needs to be examined to guess its file
type.
The implementations are registered using
TruffleLanguage registration.
TruffleFile.detectMimeType(),
TruffleLanguage.Registration.fileTypeDetectors()| Modifier and Type | Method and Description |
|---|---|
Charset |
findEncoding(TruffleFile file)
For a file containing an encoding information returns the encoding.
|
String |
findMimeType(TruffleFile file)
Finds a MIME type for given
TruffleFile. |
String findMimeType(TruffleFile file) throws IOException
TruffleFile.file - the file to find a MIME type fornull if the MIME type is not recognizedIOException - of an I/O error occursSecurityException - if the implementation requires an access the file and the
FileSystem denies the operationCharset findEncoding(TruffleFile file) throws IOException
file - the file to find an encoding for. It's guaranteed that
the file has a MIME type supported by the language registering this
TruffleFile.FileTypeDetector.null if the file does not provide encodingIOException - of an I/O error occursSecurityException - if the FileSystem denies the file access