public class DirectoryWalker
extends java.lang.Object
| Constructor and Description |
|---|
DirectoryWalker(java.nio.file.Path rootDir)
Initialize with a root directory to walk.
|
| Modifier and Type | Method and Description |
|---|---|
DirectoryWalker |
filter(java.util.function.Predicate<java.nio.file.Path> pathFilter)
Adds a filter to the walked paths.
|
DirectoryWalker |
filterRoot()
Filters away the
rootDir. |
com.google.common.collect.ImmutableList<java.nio.file.Path> |
walk()
Walks
rootDir. |
com.google.common.collect.ImmutableList<java.nio.file.Path> |
walk(PathConsumer pathConsumer)
Walks
rootDir and applies pathConsumer to each file. |
public DirectoryWalker(java.nio.file.Path rootDir)
throws java.nio.file.NotDirectoryException
rootDir - the root directory.java.nio.file.NotDirectoryException - if the root directory is not a directory.public DirectoryWalker filter(java.util.function.Predicate<java.nio.file.Path> pathFilter)
pathFilter - the filter. pathFilter returns true if the path should be
accepted and false otherwise.public DirectoryWalker filterRoot()
rootDir.public com.google.common.collect.ImmutableList<java.nio.file.Path> walk(PathConsumer pathConsumer) throws java.io.IOException
pathConsumer - the consumer that is applied to each file.java.io.IOException - if the walk fails.public com.google.common.collect.ImmutableList<java.nio.file.Path> walk()
throws java.io.IOException
rootDir.java.io.IOException - if walking the files fails.