This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
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 Elasticsearch in Action this week in the Big Data 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
It is sorta covered in the JavaRanch Style Guide.
subject: Differentiate between file and a folder