Java Activation Mimetype Check initFileTypeMap()

Here you can find the source of initFileTypeMap()

Description

init File Type Map

License

Open Source License

Declaration

private static void initFileTypeMap() 

Method Source Code

//package com.java2s;
/*//w w  w . j  a  v  a 2 s .  c  om
 * Copyright (C) 2006-2007 Mindquarry GmbH, All Rights Reserved
 * 
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 */

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

public class Main {
    private static MimetypesFileTypeMap fileTypeMap = null;

    private static void initFileTypeMap() {
        fileTypeMap = new MimetypesFileTypeMap();

        // Additional MIME types
        // (http://www.forensicinnovations.com/formats-mime.html, 14 Sep 2007)
        fileTypeMap.addMimeTypes("application/atom+xml atom");
        fileTypeMap.addMimeTypes("application/msword doc dot");
        fileTypeMap.addMimeTypes("application/mspowerpoint ppt pot");
        fileTypeMap.addMimeTypes("application/msexcel xls");
        fileTypeMap.addMimeTypes("application/pdf pdf");
        fileTypeMap.addMimeTypes("application/rdf+xml rdf rss");
        fileTypeMap.addMimeTypes("application/x-vnd.openxmlformat docx docm dotx dotm");
        fileTypeMap.addMimeTypes("application/x-vnd.openxmlformat xlsx xlsm");
        fileTypeMap.addMimeTypes("application/x-vnd.openxmlformat pptx pptm potx");
        fileTypeMap.addMimeTypes("application/x-javascript js");
        fileTypeMap.addMimeTypes("application/x-rar-compressed rar");
        fileTypeMap.addMimeTypes("application/x-textedit bat cmd");
        fileTypeMap.addMimeTypes("application/zip zip");
        fileTypeMap.addMimeTypes("audio/mpeg mp3");
        fileTypeMap.addMimeTypes("image/bmp bmp");
        fileTypeMap.addMimeTypes("image/gif gif");
        fileTypeMap.addMimeTypes("image/jpeg jpg jpeg jpe");
        fileTypeMap.addMimeTypes("image/png png");
        fileTypeMap.addMimeTypes("text/css css");
        fileTypeMap.addMimeTypes("text/csv csv");
        fileTypeMap.addMimeTypes("text/html htm html");
        fileTypeMap.addMimeTypes("text/xml xml");

        FileTypeMap.setDefaultFileTypeMap(fileTypeMap);
    }
}

Related

  1. getContentTypeFromFileName(String fileName)
  2. getMimeType(final String filename)
  3. getMimetype(String filename)
  4. getMimeTypeForFileName(String filename)
  5. init()
  6. isFileImage(String fileName)
  7. isImage(String fileName, boolean output)
  8. isMimeType(String a)
  9. isValidateContentType(String contentType)