Home Java Java-get-example Java Get Mime Type



Java Get Mime Type
Posted on: October 15, 2008 at 12:00 AM
To get the mime type, we have defined FileNameMap interface, that is a simple interface and available into the java.net package.

Java Get Mime Type

     

To get the mime type, we have defined FileNameMap interface, that is a simple interface and available into the java.net package. FileNameMap interface includes all the mechanism to map between a file name and mime type string in Java. 

Go through the given example to find out, how to get mime type.

 

 

Syntax for getting mime type in Java

import java.net.*;
public class GetMimeType {
public static void main(String[] args) {
 FileNameMap fileNameMap = URLConnection.getFileNameMap();
 String mimeType = fileNameMap.getContentTypeFor("alert.gif");
 System.out.println("mimeType="+ mimeType);

 }
}

Output will be displayed as:

Download Source Code

Related Tags for Java Get Mime Type:
.netjavacstringfileinterfacemapincludegettypemimenameintaipackagesimpleincludesdefinefilenametobetweeneildespeimceinmnttrtweennetnetjpackaceclesemallagemeintoackdefinedseeetwatpackincishaimellnismplandstrsimvatwssriringthavstabablaphatfacefinpleplmindo


More Tutorials from this section

Ask Questions?    Discuss: Java Get Mime Type   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.