Win a copy of Murach's Python Programming this week in the Jython/Python forum!
    Bookmark Topic Watch Topic
  • New Topic

Basic Object Serialization Question  RSS feed

 
Landon Blake
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Report post to moderator
What is the proper syntax to for read an object that has been serialized? (After the ObjectInputStream has been set-up.) Does it look anything like this?:
MyClass MyObject = objStream.readObject(ObjectIWantToRead)
Thanks for any information,
Landon
 
Rikard Qvarforth
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Report post to moderator
hello this is taken from the api
For example to read from a stream as written by the example in ObjectOutputStream:

so just add a cast to your code.
if you want to take control over the serializing of your class you should implement the readObject and writeObject methods or maby (depends) readResolve() method.
Hope it helps
//Rille
ps dont forget tue serialVersionUID if you are doing it yourself

 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Report post to moderator
Moving this thread to the I/O and Streams forum...
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Report post to moderator
I knew somebody named Landon once, but he usually went by "Crash"
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Report post to moderator
Landon, don't post the same question in multiple forums, it makes people at the Ranch very unhappy.
Closing this thread since.
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!