|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gargoylesoftware.base.util.DirectoryWalker
public class 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);
Field Summary | |
---|---|
private java.io.File |
startingDirectory_
|
Constructor Summary | |
---|---|
DirectoryWalker(java.lang.String startingDirectory)
Create an instance |
Method Summary | |
---|---|
java.util.Collection |
getDirectories(java.io.FileFilter filter)
Walk through the directory structure and return a collection containing all those directories for which the filter returns true |
java.util.Collection |
getFiles(java.io.FileFilter filter)
Walk through the directory structure and return a collection containing all those files for which the filter returns true |
java.util.Collection |
getFilesAndDirectories(java.io.FileFilter filter)
Walk through the directory structure and return a collection containing all those files and directories for which the filter returns true |
private java.util.Collection |
walk(java.io.FileFilter filter,
boolean includeFiles,
boolean includeDirectories)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final java.io.File startingDirectory_
Constructor Detail |
---|
public DirectoryWalker(java.lang.String startingDirectory)
startingDirectory
- the directory to start inMethod Detail |
---|
public java.util.Collection getFiles(java.io.FileFilter filter)
filter
- An object to determine whether or not to include this file
in the returned collection
public java.util.Collection getDirectories(java.io.FileFilter filter)
filter
- An object to determine whether or not to include this
directory in the returned collection
public java.util.Collection getFilesAndDirectories(java.io.FileFilter filter)
filter
- An object to determine whether or not to include this
file/directory in the returned collection
private java.util.Collection walk(java.io.FileFilter filter, boolean includeFiles, boolean includeDirectories)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |