E
- The stream and iterator type.class StreamIterator<E>
extends java.lang.Object
implements java.util.Iterator<E>, java.io.Closeable
Modifier and Type | Field and Description |
---|---|
private java.util.Iterator<E> |
iterator |
private java.util.stream.Stream<E> |
stream |
Modifier | Constructor and Description |
---|---|
private |
StreamIterator(java.util.stream.Stream<E> stream) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying stream.
|
boolean |
hasNext() |
static <T> java.util.Iterator<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() |
private final java.util.Iterator<E> iterator
private final java.util.stream.Stream<E> stream
private StreamIterator(java.util.stream.Stream<E> stream)
public static <T> java.util.Iterator<T> iterator(java.util.stream.Stream<T> stream)
In order to close the stream, the call site MUST either close the stream it allocated OR call the iterator until the end.
T
- The stream and iterator type.stream
- The stream iterate.public boolean hasNext()
hasNext
in interface java.util.Iterator<E>
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable