A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Take Control of Upgrading to Yosemite
Take Control of Automating Your Mac
this week in the
I/O and Streams
Only new Instance of object is serializable?
Joined: Sep 12, 2011
Dec 01, 2011 07:33:30
Hi Basicaly im trying to save my object to file, but im getting a
However if i create a new object then it works fine.
objStream.writeObject(new Checkout()); objStream.writeObject(oldCheckout);
the above code fails on the second line but the first runs?
Does anyone knwo why this is happening or how i can fix this?
Joined: Oct 27, 2005
Dec 01, 2011 13:55:25
Your old object probably has a field that is not serializable. When an object is serialized, all of its non-transient fields are also serialized, and therefore these must be serializable as well.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions
How To Answer Questions
Joined: Oct 14, 2005
Dec 01, 2011 14:05:29
And if you look at the error message more carefully, you will notice that it mentions the name of the class which was not serializable.
subject: Only new Instance of object is serializable?
Java class consisting of serialVersionUID
Custom zip file- Object storage
write/read two byte arrays to single file- please help!
How the objects are constructed at the time of de-serialization?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014