Top.Mail.Ru
February 8th, 2005 - Java developers — LiveJournal
? ?

Java developers

February 8th, 2005
 

09:10 am - Imageex_juan_gan - using loops to scan directory tree

I think I got it. Use double loop. No recursion necessary (it is hidden in tree() method).


import static com.myjavatools.lib.Files.*;

..........

    for (File dir : tree(new File("."))) {
      System.out.println(dir);
      for (File f : files(dir)) {
        System.out.println("  " + f);
      }
    }





Check out myjavatools.com - lib, version 5.
Powered by LiveJournal.com
Image