public class DefaultMediaTypePredictor extends Object implements MediaTypePredictor
MediaTypePredictor
that uses
DefaultMediaTypePredictor.CommonMediaTypes
.Modifier and Type | Class and Description |
---|---|
static class |
DefaultMediaTypePredictor.CommonMediaTypes
This enum represents file extension and MIME types of commonly used file.
|
Constructor and Description |
---|
DefaultMediaTypePredictor() |
Modifier and Type | Method and Description |
---|---|
static DefaultMediaTypePredictor |
getInstance()
Gets the singleton instance of this class.
|
MediaType |
getMediaTypeFromFile(File file)
Get the media type from a file name.
|
MediaType |
getMediaTypeFromFileName(String fileName)
Get the media type from a file name.
|
public MediaType getMediaTypeFromFile(File file)
MediaTypePredictor
getMediaTypeFromFile
in interface MediaTypePredictor
file
- the file from which to get the MediaType
.MediaType
for the give file; null
- if file
is null; "application/octet-stream" if extension not recognized.DefaultMediaTypePredictor.CommonMediaTypes.getMediaTypeFromFileName(java.lang.String)
public MediaType getMediaTypeFromFileName(String fileName)
MediaTypePredictor
MediaType
for
"*\/*", it will also return the same if the file is null
.getMediaTypeFromFileName
in interface MediaTypePredictor
fileName
- the file name from which to get the MediaType
.MediaType
for the give file; null
- if file
is null; "application/octet-stream" if extension not recognized.public static DefaultMediaTypePredictor getInstance()
Copyright © 2007-2017, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.