File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
I/O and Streams
How to get File extension?
Joined: Jun 20, 2004
Jun 22, 2004 02:09:00
I need to determine the extension (or MIME type...) of a file in JAVA..How can I do this...?
Joined: Oct 29, 2001
Jun 23, 2004 06:42:00
Getting the extension is easy.
String ext = filename.substring(filename.indexOf('.')+1);
MIME type is a bit more complex. The only place I've seen it used is in the
JavaBeans Activation Framework
which, given a data source, will use the MIME type to find applications which can handle that data. It's used in the JavaMail framework.
How To Ask Questions On JavaRanch
I agree. Here's the link:
subject: How to get File extension?
Reading a file
How to open a file with extension .rar
tar files extraction
checking file extension
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015