The Artima Developer Community
Sponsored Link

Java Buzz Forum
Getting MIME types with java.net.FileNameMap

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Simon Brown

Posts: 636
Nickname: simonbrown
Registered: Jun, 2003

Simon Brown is a Java developer, architect and author.
Getting MIME types with java.net.FileNameMap Posted: Dec 9, 2003 5:43 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Simon Brown.
Original Post: Getting MIME types with java.net.FileNameMap
Feed Title: Simon Brown's weblog
Feed URL: http://www.simongbrown.com/blog/feed.xml?flavor=rss20&category=java
Feed Description: My thoughts on Java, software development and technology.
Latest Java Buzz Posts
Latest Java Buzz Posts by Simon Brown
Latest Posts From Simon Brown's weblog

Advertisement

FileNameMap from the java.net package is a simple interface which provides a mechanism to map between a file name and a MIME type string. It's not actually something that I've come across before, even though it's existed since version 1.1 of the JDK. However, with code like the following, you can get the MIME type using the default JDK mappings that are specified in the JAVA_HOME/lib/content-types.properties file.

      FileNameMap fileNameMap = URLConnection.getFileNameMap();
      String mimeType = fileNameMap.getContentTypeFor(someFileName);

Thanks to Weiqi Gao for sending me over a patch to Pebble that made use of this technique. Useful stuff!

Read: Getting MIME types with java.net.FileNameMap

Topic: "Austrian" Economics Chatter Previous Topic   Next Topic Topic: Eclipse 3.0 M5 released

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use