Top Description Fields Constructors Methods
java.nio.file

pack-priv Class FileTreeIterator

extends Object
implements Iterator<FileTreeWalker.Event>, Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable, java.util.Iterator
Imports
java.io.Closeable, .IOException, .UncheckedIOException, java.util.Iterator, .List, .NoSuchElementException, java.nio.file.FileTreeWalker.Event

An Iterator to iterate over the nodes of a file tree.
try (FileTreeIterator iterator = new FileTreeIterator(start, maxDepth, options)) { while (iterator.hasNext()) { Event ev = iterator.next(); Path path = ev.file(); BasicFileAttributes attrs = ev.attributes(); } }
try (FileTreeIterator iterator = new FileTreeIterator(start, maxDepth, options)) {
    while (iterator.hasNext()) {
        Event ev = iterator.next();
        Path path = ev.file();
        BasicFileAttributes attrs = ev.attributes();
    }
}

Field Summary

Modifier and TypeField and Description
private FileTreeWalker.Event
private final FileTreeWalker

Constructor Summary

AccessConstructor and Description
pack-priv
FileTreeIterator(Path start, int maxDepth, FileVisitOption... options)

Creates a new iterator to walk the file tree starting at the given file.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

private void
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public FileTreeWalker.Event
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nextback to summary
private FileTreeWalker.Event next
walkerback to summary
private final FileTreeWalker walker

Constructor Detail

FileTreeIteratorback to summary
pack-priv FileTreeIterator(Path start, int maxDepth, FileVisitOption... options) throws IOException

Creates a new iterator to walk the file tree starting at the given file.

Exceptions
IOException:
if an I/O errors occurs opening the starting file
IllegalArgumentException:
if maxDepth is negative
SecurityException:
if the security manager denies access to the starting file
NullPointerException:
if start or options is null or the options array contains a null element

Method Detail

closeback to summary
public void close()

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
fetchNextIfNeededback to summary
private void fetchNextIfNeeded()
hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public FileTreeWalker.Event next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:FileTreeWalker.Event

the next element in the iteration

Annotations
@Override