• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get the directory name list?

 
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
Pie
Posts: 20545
56
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
Saloon Keeper
Posts: 15354
39
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