java.lang.Object | |
↳ | com.pnfsoftware.jeb.util.io.DirectoryEnumerator |
List (full in-memory enumeration) or iterate over a directory contents, with support for
recursion and regex file filters. The returned File Objects are real File Files passing
the File.isFile()
test.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DirectoryEnumerator(File base, String filterString, boolean recurse)
Create a new directory enumerator.
| |||||||||||
DirectoryEnumerator(File base)
Create a new directory enumerator.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
addBlackListedDirectory(String dirname)
Record a simple directory name (not path) that should not be recursively explored.
| ||||||||||
Collection<String> | getBlacklistedDirnames() | ||||||||||
Pattern | getFilter() | ||||||||||
boolean | isRecurse() | ||||||||||
Iterator<File> | iterator() | ||||||||||
List<File> |
list()
Browse the folder(s) and retrieve the matching files.
| ||||||||||
void | setFilter(Pattern pattern) | ||||||||||
void | setFilterString(String filterString, boolean matchCaseInsensitive, boolean matchUnicode) | ||||||||||
void | setRecurse(boolean recurse) |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Iterable
|
Create a new directory enumerator.
base | base folder |
---|---|
filterString | optional widlcard filter string for filenames |
recurse | true to recursively enumerate sub-directories. |
IllegalArgumentException | on initialization error |
---|
Create a new directory enumerator. The enumerator is filter-less (it matches on all files) and does not recurse over sub-directories.
Record a simple directory name (not path) that should not be recursively explored. Ignored if the enumerator is not recursive. The base directory is always explored, even if its simple name is blacklisted.
Example: 'xyz' is blacklisted, the search is recursive and starts in '/xyz':
- "/xyz/..." is explored, no matter what
- if it exists, "/xyz/xyz/..." and its sub-dirs WONT be explored
- if it exists, "/xyz/0/1/xyz/..." and its sub-dirs WONT be explored
- if it exists, file named '/xyz/xyz' or /xyz/foo/xyz" WILL be returned.
Browse the folder(s) and retrieve the matching files.
pattern | optional regex pattern, null to disable |
---|
filterString | non-null filter string; to disable filters, use
setFilter(Pattern) |
---|