public class MimeTypes extends Object
There are various solutions built into Java that depend on extra resource and configuration files. They are designed to be composable and extensible, but also unfortunately tricky to control. This is meant to be a simple solution that may eventually be subsumed by a better one.
Modifier and Type | Method and Description |
---|---|
static String |
getDefaultMimeType()
Gets the default MIME type, which is
"application/octet-stream" . |
static String |
getMimeTypeForExtension(String fileExtension)
Gets the MIME type for the file with the given extension.
|
static String |
getMimeTypeForFileName(String fileName)
Gets the MIME type for the file with the given name, by extension.
|
public static String getMimeTypeForExtension(String fileExtension)
fileExtension
- The file extension.null
, if the file extension is not recognized.public static String getMimeTypeForFileName(String fileName)
getMimeTypeForExtension(String)
to determine the
MIME type. If the extension cannot be determined, or the extension is unrecognized, this method
return null
.fileName
- The file name.null
, if the file's extension is not recognized.public static String getDefaultMimeType()
"application/octet-stream"
.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.