Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

De-serialization

 
David Marco
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm unable to understand why this program (coded my own) don't work:

If I change line 38 for this:


Then the program runs succesfylly. I'm going crazy!!
 
Bob Wheeler
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have forgotten the 't' in writeObject:

Change it and it will run smoothly.

cheers
Bob
 
Peter Murach
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,

You simply did not correctly implement your customized writeObject() method. If you look closely, you have simply swallowed a letter 't'. VM is using a default method writeObject which does not write your integer value returned by Bulb class method getPower( ). Subsequently, when you try to retrieve the value from a serialized file, readInt( ) method throws IOException.

Pete
 
David Marco
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bob and Peter, I really misspelled the method name.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It just goes to show, that some of the most simple errors can be the most frustrating to troubleshoot and solve. An extra set of eyes is often helpful.

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic