Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting files in a directory

 
Phil Chuang
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I get all the files in a directory? Equivalent to doing a dir *.* ... ?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look into java.io.File list method. You may want to write a java.io.FilenameFilter to select the files you want out of the directory.
Let us know if those are enough clues to go on, or if you'd like some samples.
 
Phil Chuang
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yah I found it, I was looking for the wrong type of object at first, then I peeked in the File definition and found everything I needed
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic