public interface ObjectStream<T> extends AutoCloseable
Objects from a stream.
This interface provides a means for iterating over the objects in a stream, it does not implement
Iterator.hasNext()are declared as throwing no checked exceptions. Thus the
IOExceptions thrown by
read()would have to be wrapped in
RuntimeExceptions, and the compiler would be unable to force users of this code to catch such exceptions.
Iterablewould mean either silently calling
reset()to guarantee that all items were always seen on each iteration, or documenting that the Iterable only iterates over the remaining elements of the ObjectStream. In either case, users not reading the documentation carefully might run into unexpected behavior.
|Modifier and Type||Method and Description|
Returns the next object.
Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly.
T read() throws IOException
IOException- if there is an error during reading
default void reset() throws IOException, UnsupportedOperationException
IOException- if there is an error during reseting the stream
default void close() throws IOException
ObjectStreamand releases all allocated resources. After close was called its not allowed to call read or reset.
IOException- if there is an error during closing the stream
Copyright © 2017 The Apache Software Foundation. All rights reserved.