public final class StreamIterator<E> extends Object implements Iterator<E>, AutoCloseable
Stream as a AutoCloseable Iterator resource that automatically closes itself when reaching the end of stream.
In order to close the stream, the call site MUST either close the stream it allocated OR call this iterator until the end.
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the underlying stream.
|
boolean |
hasNext() |
static <T> StreamIterator<T> |
iterator(java.util.stream.Stream<T> stream)
Wraps and presents a stream as a closable resource that automatically closes itself when reaching the end of stream.
|
E |
next() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemaining, removepublic void close()
close in interface AutoCloseablepublic static <T> StreamIterator<T> iterator(java.util.stream.Stream<T> stream)
Warning
In order to close the stream, the call site MUST either close the stream it allocated OR call this iterator until the end.
T - The stream and iterator type.stream - The stream iterate.