Java Content Type Get getContentType(String filename)

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

Description

get Content Type

License

Open Source License

Declaration

public static String getContentType(String filename) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.net.URLConnection;

public class Main {
    public static String getContentType(String filename) {
        return filename.endsWith(".html") ? "text/html"
                : filename.endsWith(".css") ? "text/css"
                        : filename.endsWith(".js") ? "text/javascript"
                                : URLConnection.guessContentTypeFromName(filename);
    }/*from   ww  w  . ja  v a  2s.c om*/
}

Related

  1. getContentType(File file)
  2. getContentType(final File file)
  3. getContentType(final String filename)
  4. getContentType(String boundary)
  5. getContentType(String file)
  6. getContentType(String fileName)
  7. getContentType(String name)