edu.umd.cs.findbugs
Class RecursiveFileSearch

java.lang.Object
  extended by edu.umd.cs.findbugs.RecursiveFileSearch

public class RecursiveFileSearch
extends java.lang.Object

Recursively search a directory, its subdirectories, etc. Note that the search algorithm uses a worklist, so its implementation does not use recursive method calls.

Author:
David Hovemeyer

Field Summary
private  java.lang.String baseDir
           
private  java.util.LinkedList<java.io.File> directoryWorkList
           
private  java.io.FileFilter fileFilter
           
private  java.util.ArrayList<java.lang.String> resultList
           
 
Constructor Summary
RecursiveFileSearch(java.lang.String baseDir, java.io.FileFilter fileFilter)
          Constructor.
 
Method Summary
 java.util.Iterator<java.lang.String> fileNameIterator()
          Get an iterator over the files found by the search.
 RecursiveFileSearch search()
          Perform the search.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseDir

private java.lang.String baseDir

fileFilter

private java.io.FileFilter fileFilter

directoryWorkList

private java.util.LinkedList<java.io.File> directoryWorkList

resultList

private java.util.ArrayList<java.lang.String> resultList
Constructor Detail

RecursiveFileSearch

public RecursiveFileSearch(java.lang.String baseDir,
                           java.io.FileFilter fileFilter)
Constructor.

Parameters:
baseDir - the base directory for the search
fileFilter - chooses files to add to the results, and subdirectories to continue the search in
Method Detail

search

public RecursiveFileSearch search()
                           throws java.lang.InterruptedException
Perform the search.

Returns:
this object
Throws:
java.lang.InterruptedException - if the thread is interrupted before the search completes

fileNameIterator

public java.util.Iterator<java.lang.String> fileNameIterator()
Get an iterator over the files found by the search. The full path names of the files are returned.