The Java.io.ObjectOutputStream class writes primitive data types and graphs of Java objects to an OutputStream.The objects can be read (reconstituted) using an ObjectInputStream.
Following is the declaration for Java.io.ObjectOutputStream class −
public class ObjectOutputStream extends OutputStream implements ObjectOutput, ObjectStreamConstants
|S.N.||Constructor & Description|
This provides a way for subclasses that are completely reimplementing ObjectOutputStream to not have to allocate private data just used by this implementation of ObjectOutputStream.
This creates an ObjectOutputStream that writes to the specified OutputStream.
|S.N.||Method & Description|
|1||protected void annotateClass(Class <?> cl)
Subclasses may implement this method to allow class data to be stored in the stream.
|2||protected void annotateProxyClass(Class<?> cl)
Subclasses may implement this method to store custom data in the stream along with descriptors for dynamic proxy classes.
This method closes the stream.
This method writes the non-static and non-transient fields of the current class to this stream.
|5||protected void drain()
This method drain any buffered data in ObjectOutputStream.
|6||protected boolean enableReplaceObject(boolean enable)
This method enable the stream to do replacement of objects in the stream.
This method flushes the stream.
This method retrieves the object used to buffer persistent fields to be written to the stream.
|9||protected Object replaceObject(Object obj)
This method will allow trusted subclasses of ObjectOutputStream to substitute one object for another during serialization.
This method reset will disregard the state of any objects already written to the stream.
|11||void useProtocolVersion(int version)
This method specify stream protocol version to use when writing the stream.
|12||void write(byte buf)
This method writes an array of bytes.
|13||void write(byte buf, int off, int len)
This method writes a sub array of bytes.
|14||void write(int val)
This method writes a byte.
|15||void writeBoolean(boolean val)
This method writes a boolean.
|16||void writeByte(int val)
This method writes an 8 bit byte.
|17||void writeBytes(String str)
This method writes a String as a sequence of bytes.
|18||void writeChar(int val)
This method writes a 16 bit char.
|19||void writeChars(String str)
This method writes a String as a sequence of chars.
|20||protected void writeClassDescriptor(ObjectStreamClass desc)
This method writes the specified class descriptor to the ObjectOutputStream.
|21||void writeDouble(double val)
This method writes a 64 bit double.
This method writes the buffered fields to the stream.
|23||void writeFloat(float val)
This method writes a 32 bit float.
|24||void writeInt(int val)
This method writes a 32 bit int.
|25||void writeLong(long val)
This method writes a 64 bit long.
|26||void writeObject(Object obj)
This method writes the specified object to the ObjectOutputStream.
|27||protected void writeObjectOverride(Object obj)
This method is used by subclasses to override the default writeObject method.
|28||void writeShort(int val)
This method writes a 16 bit short.
|29||protected void writeStreamHeader()
This method is provided so subclasses can append or prepend their own header to the stream.
|30||void writeUnshared(Object obj)
This method writes an "unshared" object to the ObjectOutputStream.
This class inherits methods from the following classes −