Path top = ... Set<FileVisitOption> options = ... int maxDepth = ... try (FileTreeWalker walker = new FileTreeWalker(options, maxDepth)) { FileTreeWalker.Event ev = walker.walk(top); do { process(ev); ev = walker.next(); } while (ev != null); }
Files#walkFileTree
Modifier and Type | Class and Description |
---|---|
private static class | FileTreeWalker.DirectoryNode
The element on the walking stack corresponding to a directory node. |
pack-priv static class | |
pack-priv static enum | FileTreeWalker.EventType
The event types. |
Modifier and Type | Field and Description |
---|---|
private boolean | |
private final boolean | |
private final LinkOption[] | |
private final int | |
private final ArrayDeque |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
public void | |
private BasicFileAttributes | getAttributes(Path file, boolean canUseCached)
Returns the attributes of the given file, taking into account whether the walk is following sym links is not. |
pack-priv boolean | |
pack-priv FileTreeWalker. | |
pack-priv void | pop()
Pops the directory node that is the current top of the stack so that there are no more events for the directory (including no END_DIRECTORY) event. |
pack-priv void | |
private FileTreeWalker. | |
pack-priv FileTreeWalker. | |
private boolean |
closed | back to summary |
---|---|
private boolean closed |
followLinks | back to summary |
---|---|
private final boolean followLinks |
linkOptions | back to summary |
---|---|
private final LinkOption[] linkOptions |
maxDepth | back to summary |
---|---|
private final int maxDepth |
stack | back to summary |
---|---|
private final ArrayDeque<FileTreeWalker. |
FileTreeWalker | back to summary |
---|---|
pack-priv FileTreeWalker(Collection<FileVisitOption> options, int maxDepth) Creates a
|
close | back to summary |
---|---|
public void close() Implements java. Closes/pops all directories on the stack.
|
getAttributes | back to summary |
---|---|
private BasicFileAttributes getAttributes(Path file, boolean canUseCached) throws IOException Returns the attributes of the given file, taking into account whether
the walk is following sym links is not. The
|
isOpen | back to summary |
---|---|
pack-priv boolean isOpen() Returns |
next | back to summary |
---|---|
pack-priv FileTreeWalker. Returns the next Event or |
pop | back to summary |
---|---|
pack-priv void pop() Pops the directory node that is the current top of the stack so that there are no more events for the directory (including no END_DIRECTORY) event. This method is a no-op if the stack is empty or the walker is closed. |
skipRemainingSiblings | back to summary |
---|---|
pack-priv void skipRemainingSiblings() Skips the remaining entries in the directory at the top of the stack. This method is a no-op if the stack is empty or the walker is closed. |
visit | back to summary |
---|---|
private FileTreeWalker. Visits the given file, returning the |
walk | back to summary |
---|---|
pack-priv FileTreeWalker. Start walking from the given file. |
wouldLoop | back to summary |
---|---|
private boolean wouldLoop(Path dir, Object key) Returns true if walking into the given directory would result in a file system loop/cycle. |
Modifier and Type | Field and Description |
---|---|
private final Path | |
private final Iterator | |
private final Object | |
private boolean | |
private final DirectoryStream |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
pack-priv Path | |
pack-priv Iterator | |
pack-priv Object | |
pack-priv void | |
pack-priv boolean | |
pack-priv DirectoryStream |
dir | back to summary |
---|---|
private final Path dir |
iterator | back to summary |
---|---|
private final Iterator<Path> iterator |
key | back to summary |
---|---|
private final Object key |
skipped | back to summary |
---|---|
private boolean skipped |
stream | back to summary |
---|---|
private final DirectoryStream<Path> stream |
DirectoryNode | back to summary |
---|---|
pack-priv DirectoryNode(Path dir, Object key, DirectoryStream<Path> stream) |
directory | back to summary |
---|---|
pack-priv Path directory() |
iterator | back to summary |
---|---|
pack-priv Iterator |
key | back to summary |
---|---|
pack-priv Object key() |
skip | back to summary |
---|---|
pack-priv void skip() |
skipped | back to summary |
---|---|
pack-priv boolean skipped() |
stream | back to summary |
---|---|
pack-priv DirectoryStream |
Modifier and Type | Field and Description |
---|---|
private final BasicFileAttributes | |
private final Path | |
private final IOException | |
private final FileTreeWalker. |
Access | Constructor and Description |
---|---|
private | |
pack-priv | |
pack-priv |
Modifier and Type | Method and Description |
---|---|
pack-priv BasicFileAttributes | |
pack-priv Path | |
pack-priv IOException | |
pack-priv FileTreeWalker. |
attrs | back to summary |
---|---|
private final BasicFileAttributes attrs |
file | back to summary |
---|---|
private final Path file |
ioe | back to summary |
---|---|
private final IOException ioe |
type | back to summary |
---|---|
private final FileTreeWalker. |
Event | back to summary |
---|---|
private Event(FileTreeWalker. |
Event | back to summary |
---|---|
pack-priv Event(FileTreeWalker. |
Event | back to summary |
---|---|
pack-priv Event(FileTreeWalker. |
attributes | back to summary |
---|---|
pack-priv BasicFileAttributes attributes() |
file | back to summary |
---|---|
pack-priv Path file() |
ioeException | back to summary |
---|---|
pack-priv IOException ioeException() |
type | back to summary |
---|---|
pack-priv FileTreeWalker. |
Modifier and Type | Field and Description |
---|---|
public static final FileTreeWalker. | END_DIRECTORY
End of a directory |
public static final FileTreeWalker. | ENTRY
An entry in a directory |
public static final FileTreeWalker. | START_DIRECTORY
Start of a directory |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public static FileTreeWalker. | |
public static FileTreeWalker. |
END_DIRECTORY | back to summary |
---|---|
public static final FileTreeWalker. End of a directory |
ENTRY | back to summary |
---|---|
public static final FileTreeWalker. An entry in a directory |
START_DIRECTORY | back to summary |
---|---|
public static final FileTreeWalker. Start of a directory |
EventType | back to summary |
---|---|
private EventType() |
valueOf | back to summary |
---|---|
public static FileTreeWalker. |
values | back to summary |
---|---|
public static FileTreeWalker. |