public class Streams extends Object
Constructor and Description |
---|
Streams() |
Modifier and Type | Method and Description |
---|---|
static <T> Stream<T> |
of(Iterator<T> it)
Obtain a Java 8 stream from an iterator.
|
public static final <T> Stream<T> of(Iterator<T> it)
Obtain a Java 8 stream from an iterator. If the iterator happens to
implement AutoCloseable (e.g. CloseableIterator
), the stream's
onClose behavior will close the iterator. Thus it is important to
always close the returned stream, or use within a try-with-resources:
try (Stream<Object> s = Streams.of(it)) {
// do something with s
} // auto-close
Copyright © 2015–2016 SYSTAP, LLC DBA Blazegraph. All rights reserved.