• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue reading a serialized object using ObjectInputStream  RSS feed

 
Aditya Sirohi
Ranch Hand
Posts: 93
Eclipse IDE Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am writing a dummy class to see how ObjectInputStream works. I was able to successfully serialize an Object, but have issue reading it.

Here is my Address Object class:




Class used to serialize object:





Class used to read serialized object from a file:




When i run my Deserializer class i am seeing this error:




Issue is with this line in the Deserializer class: address = (ArrayList<Address>) ois.readObject();


What can be the issue here?

Thanks
Adi
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It is complaining that you can't cast an Address object into an ArrayList object... which kinda makes sense, since you never wrote an ArrayList object into the object stream.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!