This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell 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


JavaRanch » Java Forums » Java » Java in General
Bookmark "Differentiate between file and a folder" Watch "Differentiate between file and a folder" New topic
Author

Differentiate between file and a folder

a gandhi
Greenhorn

Joined: Jan 19, 2004
Posts: 5
Hi,
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.
Thanks...
Don Kiddick
Ranch Hand

Joined: Dec 12, 2002
Posts: 580
myFile.isDirectory()
The APi is my friend.
Jim Yingst
Wanderer
Sheriff

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
 
GeeCON Prague 2014
 
subject: Differentiate between file and a folder