public static void traverse(final File directory,final IDirectoryTraverselCallback callback){
  final File[] files=directory.listFiles();
  if (files == null) {
    return;
  }
  callback.entering(directory);
  for (  final File file : files) {
    if (!file.isDirectory()) {
      callback.nextFile(file);
    }
  }
  for (  final File file : files) {
    if (file.isDirectory()) {
      traverse(file,callback);
    }
  }
  callback.leaving(directory);
}

public static void traverse ( final File directory , final IDirectoryTraverselCallback callback ) { final File [ ] files = directory . listFiles ( ) ; if ( files == null ) { return ; } callback . entering ( directory ) ; for ( final File file : files ) { if ( ! file . isDirectory ( ) ) { callback . nextFile ( file ) ; } } for ( final File file : files ) { if ( file . isDirectory ( ) ) { traverse ( file , callback ) ; } } callback . leaving ( directory ) ; }
recursively traverses through a directory .
