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
Author

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
Sheriff

Joined: Oct 27, 2005
Posts: 19958
    
  25

Check java.io.File, and especially the list() and listFiles() methods.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14667
    
  25

Class java.io.File 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: http://aspose.com/file-tools
 
subject: How to get the directory name list?