java.io
Class ObjectOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--java.io.ObjectOutputStream
All Implemented Interfaces:
DataOutput, ObjectOutput, ObjectStreamConstants

public synchronized class ObjectOutputStream
extends OutputStream
implements ObjectOutput, ObjectStreamConstants


Nested Class Summary
static class ObjectOutputStream.PutField
           
 
Field Summary
 
Fields inherited from interface java.io.ObjectStreamConstants
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING
 
Constructor Summary
protected ObjectOutputStream()
           
  ObjectOutputStream(OutputStream)
           
 
Method Summary
protected  void annotateClass(Class)
           
protected  void annotateProxyClass(Class)
           
 void close()
          Closes this output stream and releases any system resources associated with this stream.
 void defaultWriteObject()
           
protected  void drain()
           
protected  boolean enableReplaceObject(boolean)
           
 void flush()
          Flushes this output stream and forces any buffered output bytes to be written out.
 ObjectOutputStream.PutField putFields()
           
protected  Object replaceObject(Object)
           
 void reset()
           
 void useProtocolVersion(int)
           
 void write(byte[])
          Writes b.length bytes from the specified byte array to this output stream.
 void write(byte[], int, int)
          Writes len bytes from the specified byte array starting at offset off to this output stream.
 void write(int)
          Writes the specified byte to this output stream.
 void writeBoolean(boolean)
           
 void writeByte(int)
           
 void writeBytes(String)
           
 void writeChar(int)
           
 void writeChars(String)
           
protected  void writeClassDescriptor(ObjectStreamClass)
           
 void writeDouble(double)
           
 void writeFields()
           
 void writeFloat(float)
           
 void writeInt(int)
           
 void writeLong(long)
           
 void writeObject(Object)
           
protected  void writeObjectOverride(Object)
           
 void writeShort(int)
           
protected  void writeStreamHeader()
           
 void writeUnshared(Object)
           
 void writeUTF(String)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait
 

Constructor Detail

ObjectOutputStream

public ObjectOutputStream(OutputStream)
                   throws IOException

ObjectOutputStream

protected ObjectOutputStream()
                      throws IOException,
                             SecurityException
Method Detail

useProtocolVersion

public void useProtocolVersion(int)
                        throws IOException
IOException

writeObject

public final void writeObject(Object)
                       throws IOException
Specified by:
writeObject in interface ObjectOutput
IOException

writeObjectOverride

protected void writeObjectOverride(Object)
                            throws IOException
IOException

writeUnshared

public void writeUnshared(Object)
                   throws IOException
IOException

defaultWriteObject

public void defaultWriteObject()
                        throws IOException
IOException

putFields

public ObjectOutputStream.PutField putFields()
                                      throws IOException
IOException

writeFields

public void writeFields()
                 throws IOException
IOException

reset

public void reset()
           throws IOException
IOException

annotateClass

protected void annotateClass(Class)
                      throws IOException
IOException

annotateProxyClass

protected void annotateProxyClass(Class)
                           throws IOException
IOException

replaceObject

protected Object replaceObject(Object)
                        throws IOException
IOException

enableReplaceObject

protected boolean enableReplaceObject(boolean)
                               throws SecurityException
SecurityException

writeStreamHeader

protected void writeStreamHeader()
                          throws IOException
IOException

writeClassDescriptor

protected void writeClassDescriptor(ObjectStreamClass)
                             throws IOException
IOException

write

public void write(int)
           throws IOException
Description copied from class: OutputStream
Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Subclasses of OutputStream must provide an implementation for this method.

Specified by:
write in interface ObjectOutput
Specified by:
write in class OutputStream
Parameters:
- the byte.
Throws:
IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.

write

public void write(byte[])
           throws IOException
Description copied from class: OutputStream
Writes b.length bytes from the specified byte array to this output stream. The general contract for write(b) is that it should have exactly the same effect as the call write(b, 0, b.length).

Specified by:
write in interface ObjectOutput
Overrides:
write in class OutputStream
Parameters:
- the data.
Throws:
IOException - if an I/O error occurs.
See Also:
OutputStream.write(byte[], int, int)

write

public void write(byte[],
                  int,
                  int)
           throws IOException
Description copied from class: OutputStream
Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

The write method of OutputStream calls the write method of one argument on each of the bytes to be written out. Subclasses are encouraged to override this method and provide a more efficient implementation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Specified by:
write in interface ObjectOutput
Overrides:
write in class OutputStream
Parameters:
- the data.
- the start offset in the data.
- the number of bytes to write.
Throws:
IOException - if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.

flush

public void flush()
           throws IOException
Description copied from class: OutputStream
Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

The flush method of OutputStream does nothing.

Specified by:
flush in interface ObjectOutput
Overrides:
flush in class OutputStream
Throws:
IOException - if an I/O error occurs.

drain

protected void drain()
              throws IOException
IOException

close

public void close()
           throws IOException
Description copied from class: OutputStream
Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

The close method of OutputStream does nothing.

Specified by:
close in interface ObjectOutput
Overrides:
close in class OutputStream
Throws:
IOException - if an I/O error occurs.

writeBoolean

public void writeBoolean(boolean)
                  throws IOException
Specified by:
writeBoolean in interface DataOutput
IOException

writeByte

public void writeByte(int)
               throws IOException
Specified by:
writeByte in interface DataOutput
IOException

writeShort

public void writeShort(int)
                throws IOException
Specified by:
writeShort in interface DataOutput
IOException

writeChar

public void writeChar(int)
               throws IOException
Specified by:
writeChar in interface DataOutput
IOException

writeInt

public void writeInt(int)
              throws IOException
Specified by:
writeInt in interface DataOutput
IOException

writeLong

public void writeLong(long)
               throws IOException
Specified by:
writeLong in interface DataOutput
IOException

writeFloat

public void writeFloat(float)
                throws IOException
Specified by:
writeFloat in interface DataOutput
IOException

writeDouble

public void writeDouble(double)
                 throws IOException
Specified by:
writeDouble in interface DataOutput
IOException

writeBytes

public void writeBytes(String)
                throws IOException
Specified by:
writeBytes in interface DataOutput
IOException

writeChars

public void writeChars(String)
                throws IOException
Specified by:
writeChars in interface DataOutput
IOException

writeUTF

public void writeUTF(String)
              throws IOException
Specified by:
writeUTF in interface DataOutput
IOException