This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
Encounter problems using ObjectOutputStream's .reset() method
Posted by R on November 26, 2000 at 2:55 AM
There is a problem that has been bugging me. when i try to write an object using writeObject(Object o). It keeps writing the same object back to the stream instead of the one that has been modified. I need a way around this... I have heard that using reset() method will work. It does work but the problem is, i use writeInt(int i) method once to notify my client b4 i use the writeObject() method. So when i start using the reset() method. My client got streamcorruptionexception. My idea is that the reset actually reset my writeInt b4 my client reads it. Any idea on how to solve this prob? I have also try using clone() to clone my Object that i wanted to send.I had hope that by declaring a new instantace of the object and assigned it wif the cloned one that i wanted to send might work other than using reset().. however it diesn't work... any ideas?
Replies:
|