|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ObjectStream<T>
Reads Object
s from a stream.
Design Decision:
This interface provides a means for iterating over the
objects in a stream, it does not implement Iterator
or
Iterable
because:
Iterator.next()
and
Iterator.hasNext()
are declared as throwing no checked
exceptions. Thus the IOException
s thrown by read()
would
have to be wrapped in RuntimeException
s, and the compiler would be
unable to force users of this code to catch such exceptions.Iterable
would 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.
ObjectStreamException
Method Summary | |
---|---|
void |
close()
Closes the ObjectStream and releases all allocated
resources. |
T |
read()
Returns the next object. |
void |
reset()
Repositions the stream at the beginning and the previously seen object sequence will be repeated exactly. |
Method Detail |
---|
T read() throws IOException
IOException
void reset() throws IOException, UnsupportedOperationException
IOException
UnsupportedOperationException
void close() throws IOException
ObjectStream
and releases all allocated
resources. After close was called its not allowed to call
read or reset.
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |