java.lang.Object
java.io.OutputStream
java.io.ObjectOutputStream
- All Implemented Interfaces:
- Closeable, DataOutput, Flushable, ObjectOutput, ObjectStreamConstants
- See Also:
- Top Examples, Source Code,
ObjectInputStream
,
Serializable
,
Externalizable
protected void annotateClass(Class<?> cl)
throws IOException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[969]ObjectInputStream and ObjectOutputStream
By Anonymous on 2005/03/04 08:35:12 Rate
ObjectInputStream and ObjectOutputStream.
If you try to execute the following code with a input and output stream that are somehow coupled:
localin = new ObjectInputStream ( input_stream ) ;
localout= new ObjectOutputStream ( output_stream ) ;
you get some kind of deadlock. The following will work:
localout= new ObjectOutputStream ( output_stream ) ;
localin = new ObjectInputStream ( input_stream ) ;
[1827]Deadlock on InputObjectStream
By tim on 2006/09/27 11:52:58 Rate
It deadlock's because the InputObjectStream blocks until it connects to an ObjectOutputStream.
So if both sides wait for a response from the other before proceeding then they'll wait forever. Hence ObjectOutputStream first works.
protected void annotateProxyClass(Class<?> cl)
throws IOException
- See Also:
ObjectInputStream.resolveProxyClass(String[])
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void close()
throws IOException
- See Also:
- OutputStream, ObjectOutput, Closeable
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void defaultWriteObject()
throws IOException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void drain()
throws IOException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected boolean enableReplaceObject(boolean enable)
throws SecurityException
- See Also:
SerializablePermission
, SecurityManager.checkPermission(java.security.Permission)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void flush()
throws IOException
- See Also:
- OutputStream, ObjectOutput, Flushable
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected ObjectOutputStream()
throws IOException,
SecurityException
- See Also:
SerializablePermission
, SecurityManager.checkPermission(java.security.Permission)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public ObjectOutputStream(OutputStream out)
throws IOException
- See Also:
ObjectInputStream.ObjectInputStream(InputStream)
, putFields()
, ObjectOutputStream()
, NullPointerException, SecurityException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public ObjectOutputStream.PutField putFields()
throws IOException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Object replaceObject(Object obj)
throws IOException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void reset()
throws IOException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[970]Internal cache and memory leak of Object streams
By Anonymous on 2004/10/01 14:46:22 Rate
Object streams maintain an internal cache of the objects they have already read/written. This means that any object that has been transferred once does not have to be transferred a second time. However, it does not keep track of changes during the lifetime of an object. This means that, if you send an object, make a change in it, and send it again, the other end gets the old object. To ensure correct behaviour, you should use immutable objects or take care that you do not accidentally change the objects.
Unfortunately, the object stream does not flush any of its cache, which means that it just keeps growing and growing when you send more objects over it, even if they are never referred to again on the sender's side. This is in fact a kind of memory leak. This means that you have to call the reset ( ) method periodically to ensure that you do not run out of memory. Unfortunately, reset ( ) is too slow to call every time you send an object.
public void useProtocolVersion(int version)
throws IOException
- See Also:
ObjectStreamConstants.PROTOCOL_VERSION_2
, ObjectStreamConstants.PROTOCOL_VERSION_1
, IllegalArgumentException, IllegalStateException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void write(byte[] buf)
throws IOException
- See Also:
OutputStream.write(byte[], int, int)
, ObjectOutput, DataOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void write(byte[] buf,
int off,
int len)
throws IOException
- See Also:
- OutputStream, ObjectOutput, DataOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void write(int val)
throws IOException
- See Also:
- OutputStream, ObjectOutput, DataOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void writeBoolean(boolean val)
throws IOException
- See Also:
- DataOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void writeByte(int val)
throws IOException
- See Also:
- DataOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void writeBytes(String str)
throws IOException
- See Also:
- DataOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void writeChar(int val)
throws IOException
- See Also:
- DataOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void writeChars(String str)
throws IOException
- See Also:
- DataOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void writeClassDescriptor(ObjectStreamClass desc)
throws IOException
- See Also:
ObjectStreamConstants.PROTOCOL_VERSION_1
, useProtocolVersion(int)
, ObjectInputStream.readClassDescriptor()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void writeDouble(double val)
throws IOException
- See Also:
- DataOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void writeFields()
throws IOException
- See Also:
- NotActiveException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void writeFloat(float val)
throws IOException
- See Also:
- DataOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void writeInt(int val)
throws IOException
- See Also:
- DataOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void writeLong(long val)
throws IOException
- See Also:
- DataOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public final void writeObject(Object obj)
throws IOException
- See Also:
- NotSerializableException, InvalidClassException, ObjectOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[630]Save object to disc
By B { dot } Carmon Colvin on 2004/02/03 03:06:01 Rate
public void saveObjectToDisc ( Object theObject ) {
try
{
// open the file stream
FileOutputStream foStream = new FileOutputStream ( "FileName.obj" ) ;
// open the object stream
ObjectOutputStream ooStream = new ObjectOutputStream ( foStream ) ;
// write object to object stream
ooStream.writeObject ( theObject ) ;
// flush the object stream
ooStream.flush ( ) ;
// close the file stream
foStream.close ( ) ;
} catch ( IOException ex )
{
// handle exceptions here
}
}
protected void writeObjectOverride(Object obj)
throws IOException
- See Also:
writeObject(Object)
, ObjectOutputStream()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void writeShort(int val)
throws IOException
- See Also:
- DataOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void writeStreamHeader()
throws IOException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void writeUnshared(Object obj)
throws IOException
- See Also:
- InvalidClassException, NotSerializableException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1832]ObjectOutputStream Memory Leak
By Anonymous on 2006/10/13 09:04:17 Rate
After writeUnshared, you need to do call reset ( ) ; Otherwise, objects that you've written still have references to them floating around in a table of mappings of handles to the stuff, so garbage collection doesn't kick in.
public void writeUTF(String str)
throws IOException
- See Also:
- DataOutput
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples