1   import java.io.*;
2   import fi.jyu.mit.ohj2.*;
3   
4   /**
5    * Ohjelmalla käydään koko hakemistopuu lävitse
6    * @author Vesa Lappalainen
7    * @version 1.0, 21.02.2003
8    */
9   public class ListaaKaikki {
10  
11    public static void listaa_hakemisto(File nyky, String maski) {
12      File tama_hakemisto[] = nyky.listFiles();
13  
14      for (int i=0; i<tama_hakemisto.length; i++ ) {
15        File tiedosto = tama_hakemisto[i];
16        if ( tiedosto.isDirectory() )
17          listaa_hakemisto(tiedosto,maski);
18        else if ( tiedosto.getName().matches(maski) )
19  //        System.out.println(tiedosto.getAbsolutePath());
20          try {
21            System.out.println(tiedosto.getCanonicalPath());
22          } catch ( IOException e ) { }
23      }
24    }
25  
26    public static void main(String[] args) throws IOException {
27      String aloitus = ".";
28      String maski = ".*";
29      if ( args.length > 0 ) aloitus = args[0];
30      if ( args.length > 1 ) maski = args[1];
31      File nyky = new File(aloitus);
32      listaa_hakemisto(nyky,maski);
33    }
34  }
35