## com.sun.jersey.multipart.file
Class DefaultMediaTypePredictor

    java.lang.Object
      com.sun.jersey.multipart.file.DefaultMediaTypePredictor

All Implemented Interfaces:
  MediaTypePredictor

    public class DefaultMediaTypePredictor

extends java.lang.Object
implements MediaTypePredictor

Default implementation of `MediaTypePredictor` that uses `DefaultMediaTypePredictor.CommonMediaTypes`.

Author:
  imran@smartitengineering.com, Paul.Sandoz@Sun.Com

Nested Class Summary
`static class` | `DefaultMediaTypePredictor.CommonMediaTypes` This enum represents file extension and MIME types of commonly used file.

Constructor Summary
`DefaultMediaTypePredictor()`

Method Summary
`static DefaultMediaTypePredictor` | `getInstance()` Get the singleton instance of this class.
`javax.ws.rs.core.MediaType` | `getMediaTypeFromFile(java.io.File file)` Get the media type from a file name.
`javax.ws.rs.core.MediaType` | `getMediaTypeFromFileName(java.lang.String fileName)` Get the media type from a file name.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DefaultMediaTypePredictor

    public DefaultMediaTypePredictor()

Method Detail

### getMediaTypeFromFile

    public javax.ws.rs.core.MediaType getMediaTypeFromFile(java.io.File file)

  Description copied from interface: `MediaTypePredictor`
  Get the media type from a file name.

  Specified by:
    `getMediaTypeFromFile` in interface `MediaTypePredictor`
  Parameters:
    `file` - The file from which to get the `MediaType`
  Returns:
    The `MediaType` for the give file; `null` - if file is null; "application/octet-stream" if extension not recognized.
  See Also:
    `DefaultMediaTypePredictor.CommonMediaTypes.getMediaTypeFromFileName(java.lang.String)`

### getMediaTypeFromFileName

    public javax.ws.rs.core.MediaType getMediaTypeFromFileName(java.lang.String fileName)

  Description copied from interface: `MediaTypePredictor`
  Get the media type from a file name. If the file name extension is not recognised it will return `MediaType` for "*\/*", it will also return the same if the file is `null`.

  Specified by:
    `getMediaTypeFromFileName` in interface `MediaTypePredictor`
  Parameters:
    `fileName` - The file name from which to get the `MediaType`
  Returns:
    The `MediaType` for the give file; `null` - if file is null; "application/octet-stream" if extension not recognized.

### getInstance

    public static DefaultMediaTypePredictor getInstance()

  Get the singleton instance of this class.

  Returns:
    the singleton instance.

Copyright © 2017 Oracle Corporation. All Rights Reserved.