|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.OutputStream
java.io.ObjectOutputStream
public class ObjectOutputStream
An ObjectOutputStream can be used to save Java objects into a stream where the objects can be loaded later with an ObjectInputStream. Primitive data (ints, bytes, chars, etc) can also be saved.
ObjectInputStream,
ObjectOutput,
Serializable,
Externalizable| Nested Class Summary | |
|---|---|
static class |
ObjectOutputStream.PutField
Inner class to provide access to serializable fields |
| Field Summary |
|---|
| Constructor Summary | |
|---|---|
protected |
ObjectOutputStream()
Constructs a new ObjectOutputStream. |
|
ObjectOutputStream(OutputStream output)
Constructs a new ObjectOutputStream on the OutputStream output. |
| Method Summary | |
|---|---|
protected void |
annotateClass(Class<?> aClass)
Writes optional information for class aClass into the
stream represented by the receiver. |
protected void |
annotateProxyClass(Class<?> aClass)
Writes optional information for a proxy class into the stream represented by the receiver. |
void |
close()
Close this ObjectOutputStream. |
void |
defaultWriteObject()
Default method to write objects into the receiver. |
protected void |
drain()
Flushes buffered primitive data into the receiver. |
protected boolean |
enableReplaceObject(boolean enable)
Enables/disables object replacement for the receiver. |
void |
flush()
Flush this ObjectOutputStream. |
ObjectOutputStream.PutField |
putFields()
Return the PutField object for the receiver. |
protected Object |
replaceObject(Object object)
If enableReplaceObject() was activated, computes the
replacement object for the original object object and
returns the replacement. |
void |
reset()
Reset the receiver. |
void |
useProtocolVersion(int version)
Set the receiver to use the given protocol version. |
void |
write(byte[] buffer)
Writes the entire contents of the byte array buffer to
this ObjectOutputStream. |
void |
write(byte[] buffer,
int offset,
int length)
Writes length bytes from the byte array
buffer starting at offset offset to the
ObjectOutputStream. |
void |
write(int value)
Write one byte ( value) into the receiver's underlying
stream. |
void |
writeBoolean(boolean value)
Write primitive data of type boolean ( value)into the
receiver's underlying stream. |
void |
writeByte(int value)
Write primitive data of type byte ( value)into the
receiver's underlying stream. |
void |
writeBytes(String value)
Write a String as a sequence of bytes (only lower-order 8 bits of each char are written), as primitive data ( value) into the
receiver's underlying stream. |
void |
writeChar(int value)
Write primitive data of type char ( value)into the
receiver's underlying stream. |
void |
writeChars(String value)
Write a String as a sequence of char, as primitive data ( value)
into the receiver's underlying stream. |
protected void |
writeClassDescriptor(ObjectStreamClass classDesc)
Write class descriptor classDesc into the receiver. |
void |
writeDouble(double value)
Write primitive data of type double ( value)into the
receiver's underlying stream. |
void |
writeFields()
Write the fields of the object being dumped. |
void |
writeFloat(float value)
Write primitive data of type float ( value)into the
receiver's underlying stream. |
void |
writeInt(int value)
Write primitive data of type int ( value)into the
receiver's underlying stream. |
void |
writeLong(long value)
Write primitive data of type long ( value)into the
receiver's underlying stream. |
void |
writeObject(Object object)
Write object object into the receiver's underlying stream. |
protected void |
writeObjectOverride(Object object)
Method to be overridden by subclasses to write object into
the receiver's underlying stream. |
void |
writeShort(int value)
Write primitive data of type short ( value)into the
receiver's underlying stream. |
protected void |
writeStreamHeader()
Writes the ObjectOutputStream header into the underlying stream. |
void |
writeUnshared(Object object)
Write object object into the receiver's underlying stream
unshared with previously written identical objects. |
void |
writeUTF(String value)
Write primitive data of type String ( value) in UTF
format into the receiver's underlying stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected ObjectOutputStream()
throws IOException,
SecurityException
ObjectOutputStream. The representation
and proper initialization is in the hands of subclasses.
IOException
SecurityException - if subclassing this is not allowedSecurityManager.checkPermission(java.security.Permission)
public ObjectOutputStream(OutputStream output)
throws IOException
output. All writes are now filtered through this stream.
output - The non-null OutputStream to filter writes on.
IOException - If an IO exception happened when writing the object stream
header| Method Detail |
|---|
protected void annotateClass(Class<?> aClass)
throws IOException
aClass into the
stream represented by the receiver. This optional data can be read when
deserializing the class descriptor (ObjectStreamClass) for this class
from the input stream. By default no extra data is saved.
aClass - The class to annotate
IOException - If an IO exception happened when annotating the class.ObjectInputStream.resolveClass(java.io.ObjectStreamClass)
protected void annotateProxyClass(Class<?> aClass)
throws IOException
aClass - The proxy class to annotate
IOException - If an IO exception happened when annotating the class.ObjectInputStream.resolveProxyClass(java.lang.String[])
public void close()
throws IOException
close in interface Closeableclose in interface ObjectOutputclose in class OutputStreamIOException - If an error occurs attempting to close this stream.
public void defaultWriteObject()
throws IOException
IOException - If an IO error occurs attempting to write the object dataObjectInputStream.defaultReadObject()
protected void drain()
throws IOException
IOException - If an error occurs attempting to drain the data
protected boolean enableReplaceObject(boolean enable)
throws SecurityException
enable - if true, enables replacement. If false, disables replacement.
SecurityException - If the class of the receiver is not trustedreplaceObject(java.lang.Object),
ObjectInputStream.enableResolveObject(boolean)
public void flush()
throws IOException
flush in interface Flushableflush in interface ObjectOutputflush in class OutputStreamIOException - If an error occurs attempting to flush this
ObjectOutputStream.
public ObjectOutputStream.PutField putFields()
throws IOException
PutField object for the receiver. This allows
users to transfer values from actual object fields in the object being
dumped to the emulated fields represented by the PutField
returned by this method.
IOException - If an IO error occurs
NotActiveException - If this method is not called from writeObject()ObjectInputStream.defaultReadObject()
protected Object replaceObject(Object object)
throws IOException
enableReplaceObject() was activated, computes the
replacement object for the original object object and
returns the replacement. Otherwise returns object.
object - Original object for which a replacement may be defined
object
IOException - If any IO problem occurred when trying to resolve the object.enableReplaceObject(boolean),
ObjectInputStream.enableResolveObject(boolean),
ObjectInputStream.resolveObject(java.lang.Object)
public void reset()
throws IOException
IOException - If any IO problem occurred when trying to reset the receiver
public void useProtocolVersion(int version)
throws IOException
version - protocol version to be used
IOException - If an IO error occurs
public void write(byte[] buffer)
throws IOException
buffer to
this ObjectOutputStream.
write in interface DataOutputwrite in interface ObjectOutputwrite in class OutputStreambuffer - the buffer to be written
IOException - If an error occurs attempting to write to this
ObjectOutputStream.DataInput.readFully(byte[]),
DataInput.readFully(byte[], int, int)
public void write(byte[] buffer,
int offset,
int length)
throws IOException
length bytes from the byte array
buffer starting at offset offset to the
ObjectOutputStream.
write in interface DataOutputwrite in interface ObjectOutputwrite in class OutputStreambuffer - the buffer to be writtenoffset - offset in buffer to get byteslength - number of bytes in buffer to write
IOException - If an error occurs attempting to write to this OutputStream.DataInput.readFully(byte[]),
DataInput.readFully(byte[], int, int)
public void write(int value)
throws IOException
value) into the receiver's underlying
stream.
write in interface DataOutputwrite in interface ObjectOutputwrite in class OutputStreamvalue - The primitive data to write. Only the lower byte is written.
IOException - If an IO exception happened when writing the byte.DataInput.readByte()
public void writeBoolean(boolean value)
throws IOException
value)into the
receiver's underlying stream.
writeBoolean in interface DataOutputvalue - The primitive data to write
IOException - If an IO exception happened when writing the primitive data.DataInput.readBoolean()
public void writeByte(int value)
throws IOException
value)into the
receiver's underlying stream.
writeByte in interface DataOutputvalue - The primitive data to write
IOException - If an IO exception happened when writing the primitive data.DataInput.readByte(),
DataInput.readUnsignedByte()
public void writeBytes(String value)
throws IOException
value) into the
receiver's underlying stream.
writeBytes in interface DataOutputvalue - The primitive data to write
IOException - If an IO exception happened when writing the primitive data.DataInput.readFully(byte[]),
DataInput.readFully(byte[],int,int)
public void writeChar(int value)
throws IOException
value)into the
receiver's underlying stream.
writeChar in interface DataOutputvalue - The primitive data to write
IOException - If an IO exception happened when writing the primitive data.DataInput.readChar()
public void writeChars(String value)
throws IOException
value)
into the receiver's underlying stream.
writeChars in interface DataOutputvalue - The primitive data to write
IOException - If an IO exception happened when writing the primitive data.DataInput.readChar()
public void writeDouble(double value)
throws IOException
value)into the
receiver's underlying stream.
writeDouble in interface DataOutputvalue - The primitive data to write
IOException - If an IO exception happened when writing the primitive data.DataInput.readDouble()
public void writeFields()
throws IOException
PutField object, allowing users to dump
emulated fields, for cross-loading compatibility when a class definition
changes.
IOException - If an IO error occursputFields()
public void writeFloat(float value)
throws IOException
value)into the
receiver's underlying stream.
writeFloat in interface DataOutputvalue - The primitive data to write
IOException - If an IO exception happened when writing the primitive data.DataInput.readFloat()
public void writeInt(int value)
throws IOException
value)into the
receiver's underlying stream.
writeInt in interface DataOutputvalue - The primitive data to write
IOException - If an IO exception happened when writing the primitive data.DataInput.readInt()
public void writeLong(long value)
throws IOException
value)into the
receiver's underlying stream.
writeLong in interface DataOutputvalue - The primitive data to write
IOException - If an IO exception happened when writing the primitive data.DataInput.readLong()
protected void writeClassDescriptor(ObjectStreamClass classDesc)
throws IOException
classDesc into the receiver.
classDesc - The ObjectStreamClass object to dump
IOException - If an IO exception happened when writing the class
descriptor.
public final void writeObject(Object object)
throws IOException
object into the receiver's underlying stream.
writeObject in interface ObjectOutputobject - The object to write
IOException - If an IO exception happened when writing the objectObjectInputStream.readObject()
public void writeUnshared(Object object)
throws IOException
object into the receiver's underlying stream
unshared with previously written identical objects.
object - The object to write
IOException - If an IO exception happened when writing the objectObjectInputStream.readObject()
protected void writeObjectOverride(Object object)
throws IOException
object into
the receiver's underlying stream.
object - the object
IOException - If an IO exception happened when writing the object
public void writeShort(int value)
throws IOException
value)into the
receiver's underlying stream.
writeShort in interface DataOutputvalue - The primitive data to write
IOException - If an IO exception happened when writing the primitive data.DataInput.readShort(),
DataInput.readUnsignedShort()
protected void writeStreamHeader()
throws IOException
IOException - If an IO exception happened when writing the stream header.
public void writeUTF(String value)
throws IOException
value) in UTF
format into the receiver's underlying stream.
writeUTF in interface DataOutputvalue - The primitive data to write
IOException - If an IO exception happened when writing the primitive data.DataInput.readUTF()
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||