private void walk(File directory,int depth,Collection<T> results) throws IOException {
  checkIfCancelled(directory,depth,results);
  if (handleDirectory(directory,depth,results)) {
    handleDirectoryStart(directory,depth,results);
    int childDepth=depth + 1;
    if (depthLimit < 0 || childDepth <= depthLimit) {
      checkIfCancelled(directory,depth,results);
      File[] childFiles=filter == null ? directory.listFiles() : directory.listFiles(filter);
      childFiles=filterDirectoryContents(directory,depth,childFiles);
      if (childFiles == null) {
        handleRestricted(directory,childDepth,results);
      }
 else {
        for (        File childFile : childFiles) {
          if (childFile.isDirectory()) {
            walk(childFile,childDepth,results);
          }
 else {
            checkIfCancelled(childFile,childDepth,results);
            handleFile(childFile,childDepth,results);
            checkIfCancelled(childFile,childDepth,results);
          }
        }
      }
    }
    handleDirectoryEnd(directory,depth,results);
  }
  checkIfCancelled(directory,depth,results);
}

private void walk ( File directory , int depth , Collection < T > results ) throws IOException { checkIfCancelled ( directory , depth , results ) ; if ( handleDirectory ( directory , depth , results ) ) { handleDirectoryStart ( directory , depth , results ) ; int childDepth = depth + 1 ; if ( depthLimit < 0 || childDepth <= depthLimit ) { checkIfCancelled ( directory , depth , results ) ; File [ ] childFiles = filter == null ? directory . listFiles ( ) : directory . listFiles ( filter ) ; childFiles = filterDirectoryContents ( directory , depth , childFiles ) ; if ( childFiles == null ) { handleRestricted ( directory , childDepth , results ) ; } else { for ( File childFile : childFiles ) { if ( childFile . isDirectory ( ) ) { walk ( childFile , childDepth , results ) ; } else { checkIfCancelled ( childFile , childDepth , results ) ; handleFile ( childFile , childDepth , results ) ; checkIfCancelled ( childFile , childDepth , results ) ; } } } } handleDirectoryEnd ( directory , depth , results ) ; } checkIfCancelled ( directory , depth , results ) ; }
main recursive method to examine the directory hierarchy .
