File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Differentiate between file and a folder Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Differentiate between file and a folder" Watch "Differentiate between file and a folder" New topic

Differentiate between file and a folder

a gandhi

Joined: Jan 19, 2004
Posts: 5
I am getting all the files from a folder. A folder can have files and subfolders also. I want to know if there is a way in java to differentiate between a folder and a file.
Don Kiddick
Ranch Hand

Joined: Dec 12, 2002
Posts: 580
The APi is my friend.
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
The File class has an isDirectory() method which should be what you want.

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: Differentiate between file and a folder
Similar Threads
Corp to corp
finding packages
How to add icons along with the text in a JList[urgent]
Using different versions of jar files