Java Byte Stream ObjectInputStream/ObjectOutputStream

ObjectInputStream Constructor

Constructor Description
ObjectInputStream(InputStream in) Creates an ObjectInputStream object for unmarshalling from in.

ObjectInputStream Methods

Method Description
int available() Returns the byte value that can be read from the object.
void close() Closes the object.
void defaultReadObject() Reads non-static and non-transient objects from the current Stream.
protected boolean enableResolveObject(boolean enable) Sets whether reading objects from the current Stream is allowed.
int read() Reads data in byte units.
int read(byte[] buf, int off, int len) Reads from off to len into the buf byte array.
boolean readBoolean() Reads the boolean value of the object.
byte readByte() Reads 1 byte from the object. (8 bits)
char readChar() Reads 1 char from the object. (16 bits)
protected ObjectStreamClass readClassDescriptor() Reads the Descriptor from the serialized stream.
double readDouble() Reads 1 double from the object. (64 bits)
ObjectInputStream.GetField.readFields() Gets the names of persistent fields from the object.
float readFloat() Reads 1 float from the object. (32 bits)
void readFully(byte[] buf) Reads buf-sized bytes from the object.
void readFully(byte[] buf, int off, int len) Reads len bytes from off into buf from the object.
int readInt() Reads 1 int from the object. (32 bits)
Long readLong() Reads 1 Long from the object. (64 bits)
Object readObject() Reads an Object from the object.
Short readShort() Reads 1 Short from the object. (16 bits)
protected void readStreamHeader() Reads the stream header.
Object readUnshared() Reads an “unshared” object from the stream.
String readUTF() Reads a String using UTF-8.

ObjectOutputStream Constructor

Constructor Description
ObjectOutputStream(OutputStream out) Creates an ObjectOutputStream object for marshalling out.

ObjectOutputStream Methods

Method Description
void close() Closes the object.
void defaultWriteObject() Writes non-static and non-transient objects to the current Stream.
protected void drain() Sends out objects in the ObjectOutputStream buffer.
protected boolean enableReplaceObject(boolean enable) Sets whether writing objects to the current Stream is allowed.
void flush() Sends data to the stream.
protected Object replaceObject(Object obj) Replaces an Object in the object.
void reset() Resets the stream.
void useProtocolVersion(int version) Sets the protocol version used when sending out the stream.
void write(byte[] buf) Writes buf.
void write(byte[] buf, int off, int len) Writes len bytes from off in buf to the stream.
void write(int val) Writes val bytes to the stream.
void writeBoolean(boolean val) Writes val to the stream.
void writeByte(int val) Writes val as a byte to the stream. (8 bits)
void writeBytes(String str) Writes str as sequence bytes to the stream.
void writeChar(int val) Writes val as a char to the stream. (16 bits)
void writeChars(String str) Writes str as a sequence of chars to the stream.
protected void writeClassDescriptor(ObjectStreamClass desc) Writes desc to the stream.
void writeDouble(double val) Writes val as a Double to the stream. (64 bits)
void writeFields() Writes the fields in the buffer to the stream.
void writeFloat(float val) Writes val as a Float to the stream. (32 bits)
void writeInt(int val) Writes val as an Int to the stream. (32 bits)
void writeLong(long val) Writes val as a long to the stream. (64 bits)
void writeObject(Object obj) Writes the obj object to the stream.
void writeShort(int val) Writes val as a Short to the stream.
protected void writeStreamHeader() Writes StreamHeader to the stream.
void writeUnshared(Object obj) Writes an “unshared” object to the stream.
void writeUTF(String str) Sets the character encoding of the object to UTF-8.