Save This Page
Home » apache-harmony-6.0-src-r917296-snapshot » java » io » [javadoc | source]
java.io
public class: ObjectOutputStream [javadoc | source]
java.lang.Object
   java.io.OutputStream
      java.io.ObjectOutputStream

All Implemented Interfaces:
    ObjectStreamConstants, ObjectOutput, Flushable, Closeable

Direct Known Subclasses:
   

A specialized OutputStream that is able to write (serialize) Java objects as well as primitive data types (int, byte, char etc.). The data can later be loaded using an ObjectInputStream.
Nested Class Summary:
abstract public static class  ObjectOutputStream.PutField  PutField is an inner class to provide access to the persistent fields that are written to the target stream. 
Constructor:
 protected ObjectOutputStream() throws IOException, SecurityException 
    Constructs a new {@code ObjectOutputStream}. This default constructor can be used by subclasses that do not want to use the public constructor if it allocates unneeded data.
    Throws:
    IOException - if an error occurs when creating this stream.
    SecurityException - if a security manager is installed and it denies subclassing this class.
    Also see:
    SecurityManager#checkPermission(java.security.Permission)
 public ObjectOutputStream(OutputStream output) throws IOException 
    Constructs a new ObjectOutputStream that writes to the OutputStream {@code output}.
    Parameters:
    output - the non-null OutputStream to filter writes on.
    Throws:
    IOException - if an error occurs while writing the object stream header
    SecurityException - if a security manager is installed and it denies subclassing this class.
Method from java.io.ObjectOutputStream Summary:
annotateClass,   annotateProxyClass,   close,   defaultWriteObject,   drain,   enableReplaceObject,   flush,   putFields,   replaceObject,   reset,   useProtocolVersion,   write,   write,   write,   writeBoolean,   writeByte,   writeBytes,   writeChar,   writeChars,   writeClassDescriptor,   writeDouble,   writeFields,   writeFloat,   writeInt,   writeLong,   writeObject,   writeObjectOverride,   writeShort,   writeStreamHeader,   writeUTF,   writeUnshared
Methods from java.io.OutputStream:
checkError,   close,   flush,   write,   write,   write
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.io.ObjectOutputStream Detail:
 protected  void annotateClass(Class<?> aClass) throws IOException 
    Writes optional information for class {@code aClass} to the output stream. This optional data can be read when deserializing the class descriptor (ObjectStreamClass) for this class from an input stream. By default, no extra data is saved.
 protected  void annotateProxyClass(Class<?> aClass) throws IOException 
    Writes optional information for a proxy class to the target stream. This optional data can be read when deserializing the proxy class from an input stream. By default, no extra data is saved.
 public  void close() throws IOException 
    Closes this stream. Any buffered data is flushed. This implementation closes the target stream.
 public  void defaultWriteObject() throws IOException 
    Default method to write objects to this stream. Serializable fields defined in the object's class and superclasses are written to the output stream.
 protected  void drain() throws IOException 
    Writes buffered data to the target stream. This is similar to {@code flush} but the flush is not propagated to the target stream.
 protected boolean enableReplaceObject(boolean enable) throws SecurityException 
    Enables object replacement for this stream. By default this is not enabled. Only trusted subclasses (loaded with system class loader) are allowed to change this status.
 public  void flush() throws IOException 
    Writes buffered data to the target stream and calls the {@code flush} method of the target stream.
 public PutField putFields() throws IOException 
    Gets this stream's {@code PutField} object. This object provides access to the persistent fields that are eventually written to the output stream. It is used to transfer the values from the fields of the object that is currently being written to the persistent fields.
 protected Object replaceObject(Object object) throws IOException 
    Allows trusted subclasses to substitute the specified original {@code object} with a new object. Object substitution has to be activated first with calling {@code enableReplaceObject(true)}. This implementation just returns {@code object}.
 public  void reset() throws IOException 
    Resets the state of this stream. A marker is written to the stream, so that the corresponding input stream will also perform a reset at the same point. Objects previously written are no longer remembered, so they will be written again (instead of a cyclical reference) if found in the object graph.
 public  void useProtocolVersion(int version) throws IOException 
    Sets the specified protocol version to be used by this stream.
 public  void write(byte[] buffer) throws IOException 
    Writes the entire contents of the byte array {@code buffer} to the output stream. Blocks until all bytes are written.
 public  void write(int value) throws IOException 
    Writes a single byte to the target stream. Only the least significant byte of the integer {@code value} is written to the stream. Blocks until the byte is actually written.
 public  void write(byte[] buffer,
    int offset,
    int length) throws IOException 
    Writes {@code count} bytes from the byte array {@code buffer} starting at offset {@code index} to the target stream. Blocks until all bytes are written.
 public  void writeBoolean(boolean value) throws IOException 
    Writes a boolean to the target stream.
 public  void writeByte(int value) throws IOException 
    Writes a byte (8 bit) to the target stream.
 public  void writeBytes(String value) throws IOException 
    Writes the string {@code value} as a sequence of bytes to the target stream. Only the least significant byte of each character in the string is written.
 public  void writeChar(int value) throws IOException 
    Writes a character (16 bit) to the target stream.
 public  void writeChars(String value) throws IOException 
    Writes the string {@code value} as a sequence of characters to the target stream.
 protected  void writeClassDescriptor(ObjectStreamClass classDesc) throws IOException 
    Writes a class descriptor to the target stream.
 public  void writeDouble(double value) throws IOException 
    Writes a double (64 bit) to the target stream.
 public  void writeFields() throws IOException 
    Writes the fields of the object currently being written to the target stream. The field values are buffered in the currently active {@code PutField} object, which can be accessed by calling {@code putFields()}.
 public  void writeFloat(float value) throws IOException 
    Writes a float (32 bit) to the target stream.
 public  void writeInt(int value) throws IOException 
    Writes an integer (32 bit) to the target stream.
 public  void writeLong(long value) throws IOException 
    Writes a long (64 bit) to the target stream.
 public final  void writeObject(Object object) throws IOException 
    Writes an object to the target stream.
 protected  void writeObjectOverride(Object object) throws IOException 
    Method to be overridden by subclasses to write {@code object} to the target stream.
 public  void writeShort(int value) throws IOException 
    Writes a short (16 bit) to the target stream.
 protected  void writeStreamHeader() throws IOException 
 public  void writeUTF(String value) throws IOException 
 public  void writeUnshared(Object object) throws IOException 
    Writes an unshared object to the target stream. This method is identical to {@code writeObject}, except that it always writes a new object to the stream versus the use of back-referencing for identical objects by {@code writeObject}.