permaculture playing cards
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 Elasticsearch in Action this week in the Big Data 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: 19908

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: 14599

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
It is sorta covered in the JavaRanch Style Guide.
subject: How to get the directory name list?