public static void walkFileTree(File directory,FileTreeVisitor visitor){
  visitor.preVisitDirectory(directory);
  File[] files=directory.listFiles();
  if (files != null) {
    for (    File file : files) {
      if (file.isDirectory()) {
        walkFileTree(file,visitor);
      }
 else {
        visitor.visitFile(file);
      }
    }
  }
  visitor.postVisitDirectory(directory);
}

public static void walkFileTree ( File directory , FileTreeVisitor visitor ) { visitor . preVisitDirectory ( directory ) ; File [ ] files = directory . listFiles ( ) ; if ( files != null ) { for ( File file : files ) { if ( file . isDirectory ( ) ) { walkFileTree ( file , visitor ) ; } else { visitor . visitFile ( file ) ; } } } visitor . postVisitDirectory ( directory ) ; }
iterates over the file tree of a directory . it receives a visitor and will call its methods for each file in the directory . previsitdirectory ( directory ) visitfile ( file ) - recursively the same for every subdirectory postvisitdirectory ( directory )
