|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jut.io.DirectoryTree
public class DirectoryTree
Iterable
recursively iterating through the files of a directory tree. iteration is done
breadth first.
Nested Class Summary | |
---|---|
static class |
DirectoryTree.DirFilter
directory listing filter. this base filter class just returns all children of a directory. |
Constructor Summary | |
---|---|
DirectoryTree(File root)
create an Iterable recursively iterating through the files of a directory tree. the
Iterator s of this Iterable are not thread-safe. |
|
DirectoryTree(File root,
boolean onlyEmptyDirs)
create an Iterable recursively iterating through all files of a directory tree passing
the filter provided. the Iterator s of this Iterable are not thread-safe. |
|
DirectoryTree(File root,
ParamCallable<List<File>,File> filter)
create an Iterable recursively iterating through all files of a directory tree passing
the filter provided. the Iterator s of this Iterable are not thread-safe. |
|
DirectoryTree(File root,
ParamCallable<List<File>,File> filter,
boolean onlyEmptyDirs)
create an Iterable recursively iterating through all files of a directory tree passing
the filter provided. the Iterator s of this Iterable are not thread-safe. |
Method Summary | |
---|---|
Iterator<File> |
iterator()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DirectoryTree(File root) throws IllegalArgumentException
Iterable
recursively iterating through the files of a directory tree. the
Iterator
s of this Iterable
are not thread-safe.
root
- - the root directory of the file tree to iterate through.
IllegalArgumentException
- if the root file is not a directory.public DirectoryTree(File root, ParamCallable<List<File>,File> filter) throws IllegalArgumentException
Iterable
recursively iterating through all files of a directory tree passing
the filter provided. the Iterator
s of this Iterable
are not thread-safe.
root
- - the root directory of the file tree to iterate through.filter
- - a filter called for each directory encountered. the filter must return all
directories and files contained that pass this filter stage. note that directories
returned will also be fed into the filter to get their contents as soon as they are
requested by the next() method. null
can be set for the pass-all filter.
the filter's Iterator
will be used internally. custom filters should either
subclass DirectoryTree.DirFilter
and call the DirectoryTree.DirFilter.call(File)
method to get the
initial list of files to filter or use Files.listFiles(File)
. that way,
directory listing can be adapted globally as described in
Files.listFiles(File)
e.g. for implementing a a file access speed limit.
IllegalArgumentException
- if the root file is not a directory.public DirectoryTree(File root, boolean onlyEmptyDirs) throws IllegalArgumentException
Iterable
recursively iterating through all files of a directory tree passing
the filter provided. the Iterator
s of this Iterable
are not thread-safe.
root
- - the root directory of the file tree to iterate through.onlyEmptyDirs
- - false if all directories are to be returned, true if only empty
directories (i.e. directories without content after filtering) are to be returned.
IllegalArgumentException
- if the root file is not a directory.public DirectoryTree(File root, ParamCallable<List<File>,File> filter, boolean onlyEmptyDirs) throws IllegalArgumentException
Iterable
recursively iterating through all files of a directory tree passing
the filter provided. the Iterator
s of this Iterable
are not thread-safe.
root
- - the root directory of the file tree to iterate through.filter
- - a filter called for each directory encountered. the filter must return all
directories and files contained that pass this filter stage. note that directories
returned will also be fed into the filter to get their contents as soon as they are
requested by the next() method. null
can be set for the pass-all filter.
the filter's Iterator
will be used internally. custom filters should either
subclass DirectoryTree.DirFilter
and call the DirectoryTree.DirFilter.call(File)
method to get the
initial list of files to filter or use Files.listFiles(File)
. that way,
directory listing can be adapted globally as described in
Files.listFiles(File)
e.g. for implementing a a file access speed limit.onlyEmptyDirs
- - false if all directories are to be returned, true if only empty
directories (i.e. directories without content after filtering) are to be returned.
IllegalArgumentException
- if the root file is not a directory.Method Detail |
---|
public Iterator<File> iterator()
iterator
in interface Iterable<File>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |