/** * Closes the stream. This method must be called to release any resources * associated with the stream. * * @throws IOException If an I/O error has occurred. */ public void close() throws IOException { flush(); clear(); bout.close(); }
/** * Closes the stream. This method must be called to release any resources * associated with the stream. * * @throws IOException If an I/O error has occurred. */ public void close() throws IOException { flush(); clear(); bout.close(); }
/** * Attempts to write to stream fatal IOException that has caused * serialization to abort. */ private void writeFatalException(IOException ex) throws IOException { /* * Note: the serialization specification states that if a second * IOException occurs while attempting to serialize the original fatal * exception to the stream, then a StreamCorruptedException should be * thrown (section 2.1). However, due to a bug in previous * implementations of serialization, StreamCorruptedExceptions were * rarely (if ever) actually thrown--the "root" exceptions from * underlying streams were thrown instead. This historical behavior is * followed here for consistency. */ clear(); boolean oldMode = bout.setBlockDataMode(false); try { bout.writeByte(TC_EXCEPTION); writeObject0(ex, false); clear(); } finally { bout.setBlockDataMode(oldMode); } }
/** * Reset will disregard the state of any objects already written to the * stream. The state is reset to be the same as a new ObjectOutputStream. * The current point in the stream is marked as reset so the corresponding * ObjectInputStream will be reset at the same point. Objects previously * written to the stream will not be refered to as already being in the * stream. They will be written to the stream again. * * @throws IOException if reset() is invoked while serializing an object. */ public void reset() throws IOException { if (depth != 0) { throw new IOException("stream active"); } bout.setBlockDataMode(false); bout.writeByte(TC_RESET); clear(); bout.setBlockDataMode(true); }
/** * Attempts to write to stream fatal IOException that has caused * serialization to abort. */ private void writeFatalException(IOException ex) throws IOException { /* * Note: the serialization specification states that if a second * IOException occurs while attempting to serialize the original fatal * exception to the stream, then a StreamCorruptedException should be * thrown (section 2.1). However, due to a bug in previous * implementations of serialization, StreamCorruptedExceptions were * rarely (if ever) actually thrown--the "root" exceptions from * underlying streams were thrown instead. This historical behavior is * followed here for consistency. */ clear(); boolean oldMode = bout.setBlockDataMode(false); try { bout.writeByte(TC_EXCEPTION); writeObject0(ex, false); clear(); } finally { bout.setBlockDataMode(oldMode); } }
/** * Reset will disregard the state of any objects already written to the * stream. The state is reset to be the same as a new ObjectOutputStream. * The current point in the stream is marked as reset so the corresponding * ObjectInputStream will be reset at the same point. Objects previously * written to the stream will not be refered to as already being in the * stream. They will be written to the stream again. * * @throws IOException if reset() is invoked while serializing an object. */ public void reset() throws IOException { if (depth != 0) { throw new IOException("stream active"); } bout.setBlockDataMode(false); bout.writeByte(TC_RESET); clear(); bout.setBlockDataMode(true); }