Package com.gargoylesoftware.base.util
Class DirectoryWalker
java.lang.Object
com.gargoylesoftware.base.util.DirectoryWalker
A class to walk through the directory structure from a given starting point
and return either files or directories or both.
The following sample gets all java files.
final FileFilter filter = new FileFilter() { public boolean accept( final File file ) { return file.getName().endsWith(".java"); } }; final DirectoryWalker directoryWalker = new DirectoryWalker("."); final Collection files = directoryWalker.getFiles(filter);
- Version:
- $Revision: 1.5 $
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetDirectories
(FileFilter filter) Walk through the directory structure and return a collection containing all those directories for which the filter returns truegetFiles
(FileFilter filter) Walk through the directory structure and return a collection containing all those files for which the filter returns truegetFilesAndDirectories
(FileFilter filter) Walk through the directory structure and return a collection containing all those files and directories for which the filter returns trueprivate Collection
walk
(FileFilter filter, boolean includeFiles, boolean includeDirectories)
-
Field Details
-
startingDirectory_
-
-
Constructor Details
-
DirectoryWalker
Create an instance- Parameters:
startingDirectory
- the directory to start in
-
-
Method Details
-
getFiles
Walk through the directory structure and return a collection containing all those files for which the filter returns true- Parameters:
filter
- An object to determine whether or not to include this file in the returned collection- Returns:
- A collection of File objects
-
getDirectories
Walk through the directory structure and return a collection containing all those directories for which the filter returns true- Parameters:
filter
- An object to determine whether or not to include this directory in the returned collection- Returns:
- A collection of File objects
-
getFilesAndDirectories
Walk through the directory structure and return a collection containing all those files and directories for which the filter returns true- Parameters:
filter
- An object to determine whether or not to include this file/directory in the returned collection- Returns:
- A collection of File objects
-
walk
-