Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Listing Subdirectories  RSS feed

 
Tristan Havelick
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to create a method that will list all subdirectories of a given directory. I know how to use the listFiles() method of the file object to list files within a directory and filter them based on their name, but how can I filter out files that are not directories?
Thanks,
Tristan
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tristan,
You can use the !File.isFile() or File.isDirectory() method to tell you whether the File object is a directory.
-Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!