private static class FileFinder.Finder extends java.nio.file.SimpleFileVisitor<java.nio.file.Path>
findFiles(...) methods to actually
"walk" the directory tree.| Modifier and Type | Field and Description |
|---|---|
private java.nio.file.PathMatcher |
matcher
Pattern matcher.
|
private java.util.List<java.lang.String> |
matches
String representations of matching Paths. |
| Constructor and Description |
|---|
Finder(java.lang.String pattern)
Creates a new file searcher.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
done()
Prints the total number of matches to standard out.
|
(package private) void |
find(java.nio.file.Path file)
Compare the given file or directory against the glob pattern.
|
java.nio.file.FileVisitResult |
preVisitDirectory(java.nio.file.Path dir,
java.nio.file.attribute.BasicFileAttributes attrs)
Invokes the pattern matching method on the given directory.
|
(package private) java.util.List<java.lang.String> |
results()
Returns the matching paths as strings.
|
java.nio.file.FileVisitResult |
visitFile(java.nio.file.Path file,
java.nio.file.attribute.BasicFileAttributes attrs)
Invokes pattern matching method on the given file.
|
java.nio.file.FileVisitResult |
visitFileFailed(java.nio.file.Path file,
java.io.IOException exc)
Handle file "visitation" errors.
|
private final java.nio.file.PathMatcher matcher
private final java.util.List<java.lang.String> matches
String representations of matching Paths.Finder(java.lang.String pattern)
Please see FileSystem.getPathMatcher(String) for more
details concerning patterns.
pattern - Pattern to match against.void find(java.nio.file.Path file)
If file matches, it is added to matches.
file - File (or directory) to compare against the glob pattern.results()void done()
java.util.List<java.lang.String> results()
List of the matching paths as String values.public java.nio.file.FileVisitResult visitFile(java.nio.file.Path file, java.nio.file.attribute.BasicFileAttributes attrs)
visitFile in interface java.nio.file.FileVisitor<java.nio.file.Path>visitFile in class java.nio.file.SimpleFileVisitor<java.nio.file.Path>file - File in question.attrs - Attributes of dir. Not currently used.FileVisitResult.CONTINUE (for now).public java.nio.file.FileVisitResult preVisitDirectory(java.nio.file.Path dir, java.nio.file.attribute.BasicFileAttributes attrs)
preVisitDirectory in interface java.nio.file.FileVisitor<java.nio.file.Path>preVisitDirectory in class java.nio.file.SimpleFileVisitor<java.nio.file.Path>dir - Directory in question.attrs - Attributes of dir. Not currently used.FileVisitResult.CONTINUE (for now).public java.nio.file.FileVisitResult visitFileFailed(java.nio.file.Path file, java.io.IOException exc)
visitFileFailed in interface java.nio.file.FileVisitor<java.nio.file.Path>visitFileFailed in class java.nio.file.SimpleFileVisitor<java.nio.file.Path>file - File that could not be "visited".exc - Exception associated with "visit" to
file.FileVisitResult.CONTINUE (for now).