• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get the directory name list?  RSS feed

 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check java.io.File, and especially the list() and listFiles() methods.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!