Java Activation Mimetype Check getContentType(String filePath)

Here you can find the source of getContentType(String filePath)

Description

Returns the mime type of the given file.

License

Open Source License

Parameter

Parameter Description
filePath the file path and name

Return

String

Declaration

public static final String getContentType(String filePath) 

Method Source Code

//package com.java2s;

import javax.activation.FileTypeMap;
import javax.activation.MimetypesFileTypeMap;

public class Main {
    /**/*from   ww  w. j  av  a 2 s  .c  om*/
     * Returns the mime type of the given file.
     * @param filePath the file path and name
     * @return String
     */
    public static final String getContentType(String filePath) {
        FileTypeMap map = MimetypesFileTypeMap.getDefaultFileTypeMap();
        return map.getContentType(filePath);
    }
}

Related

  1. copyMimeType(final MimeType original)
  2. createWildcard()
  3. equal(String string1, String string2)
  4. getContentType(String filename)
  5. getContentTypeFromFileName(String fileName)
  6. getMimeType(final String filename)
  7. getMimetype(String filename)
  8. getMimeTypeForFileName(String filename)