my dog learned polymorphism*
The moose likes I/O and Streams and the fly likes How to find the extention of file 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 » I/O and Streams
Bookmark "How to find the extention of file" Watch "How to find the extention of file" New topic

How to find the extention of file

Shyam Purkayastha
Ranch Hand

Joined: Jan 15, 2001
Posts: 57
Hi all
Whenever we use a JFileChooser to get a file it returns a File object.My question is weather it is possible to get the file extension string from the File object.If yes then how?
Mag Hoehme
Ranch Hand

Joined: Apr 07, 2002
Posts: 194
Hi Shyam,
the extension is the substring beginning with the last dot. For example:

Hope this helps.

li dalong

Joined: Nov 14, 2002
Posts: 2
I want to think return .exe?what do me??
It is sorta covered in the JavaRanch Style Guide.
subject: How to find the extention of file
Similar Threads
how to get the web link of uploaded file on web server?
getting a file name
file path?
java io
non-networked and network mode