public class DefaultFileParametersDetector extends Object implements FileParametersDetector
FileParametersDetector interface. Its purpose is to define MIMEType by a file.
It is based on two methods:
Files.probeContentType(Path)URLConnection.guessContentTypeFromName(String)These methods are used in the same order as above in the text. If its can't define MIMEType
then the detectMimeType(File) method will return
the default value (application/octet-stream).
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_CONTENT_TYPE |
| Constructor and Description |
|---|
DefaultFileParametersDetector() |
| Modifier and Type | Method and Description |
|---|---|
Charset |
detectEncoding(File file)
Returns always system default charset.
|
String |
detectMimeType(File file)
Returns MIMEType by a file.
|
public static final String DEFAULT_CONTENT_TYPE
public String detectMimeType(File file)
It uses the next methods: Files.probeContentType(Path) and
URLConnection.guessContentTypeFromName(String) or else returns the default value
from the constant DEFAULT_CONTENT_TYPE
detectMimeType in interface FileParametersDetectorfile - a file from which it will take MIMETypepublic Charset detectEncoding(File file)
FileParametersDetector interface.detectEncoding in interface FileParametersDetectorfile - a file for getting content charsetCopyright © 2023. All rights reserved.