• Post Reply Bookmark Topic Watch Topic
  • New Topic

JDK 1.5 (also 1.4.2) and file tree walking  RSS feed

 
Rob Marshall
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Sorry, but I'm a little confused...I am writing some stuff using JDK 1.5 and I need to be able to walk a file tree. It looks like (and this is where I'm confused) that the file tree walking functionality in NIO isn't available until JDK7. Is that correct?

How do I walk a file tree in 1.5? Or in 1.4.2 for that matter?

Thanks,

Rob
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
File.listFiles().
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or Apache Commons-IO, which has a directory walker method.
 
Rob Marshall
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll have to look at Apache Commons-IO, but for now I'm using File.listFiles() with recursion.

Thanks,

Rob
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The IO method does the recursion for you and allows for composition of file selection filters--it's convenient, but not hugely more so for little things.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!