Home Java Java-get-example Java Get Mime Type
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Java Get Mime Type

Advertisement
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

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 15, 2008

Ask Questions?    Discuss: Java Get Mime Type  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
how can i start my java course from begining
August 28, 2011
java

it's nice
DMCA.com