Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Beginning Java and the fly likes How to get the directory name list? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to get the directory name list?" Watch "How to get the directory name list?" New topic

How to get the directory name list?

Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
I would liek to get the list of directories under C:/testing/ directory. There are many folders under this directory. I just need their names. Do I have to hard code "C:/testing" to give absolute path to get their names.
Thanks and Regards
Rob Spoor

Joined: Oct 27, 2005
Posts: 19958

Check, and especially the list() and listFiles() methods.

How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14667

Class has methods to list the files and directories inside a directory. To get the names of the subdirectories of C:/testing, you could do this:

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: How to get the directory name list?