public interface ObjectStream<T> extends Iterable<T>, Closeable
A stream of objects read from somewhere.
This interface extends Iterable
for convenience; the Iterable.iterator()
method does not return a fresh iterator but rather a wrapper of this stream. It is only present to allow for-each loops over streams. After it is exhausted, any iterator returned will be null.
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the stream.
|
T |
readObject()
Read the next object from this stream.
|
forEach, iterator, spliterator
@CheckForNull T readObject()
Read the next object from this stream.
null
if at the end of the stream.void close()
Close the stream. This invalidates the stream; no more elements may be fetched after a call to close()
(although implementations are not required to enforce this). It is not an error to close a stream multiple times.
close
in interface AutoCloseable
close
in interface Closeable