This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes How to get file extension? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to get file extension?" Watch "How to get file extension?" New topic

How to get file extension?

Siripa Siangklom
Ranch Hand

Joined: Jan 26, 2004
Posts: 79
A content-type/mime-type to file extension mapping is ambiguous. For example:
image/jpeg can be .jpg or .jpeg file.
How to get file extension exactly from content type?
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
There is no way to do this. In fact, there is no particular reason why a file should even have a file extension.
Can you explain a little more about what you are trying to achieve by doing this? It's quite likely we can come up with alternative solutions.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Consider Paul's rocket mass heater.
subject: How to get file extension?
Similar Threads
Mistakenly changed web.xml
Web logic server file direct download
Get File Type
checking content type of file upload?
Can I change the response mime type midway?