aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes De-serialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "De-serialization" Watch "De-serialization" New topic
Author

De-serialization

David Marco
Ranch Hand

Joined: Feb 23, 2009
Posts: 44
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!!


SCJP 6
Bob Wheeler
Ranch Hand

Joined: Apr 24, 2009
Posts: 317
You have forgotten the 't' in writeObject:

Change it and it will run smoothly.

cheers
Bob


SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
Peter Murach
Greenhorn

Joined: Feb 08, 2009
Posts: 5
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


The important thing is not to stop questioning.

Albert Einstein
David Marco
Ranch Hand

Joined: Feb 23, 2009
Posts: 44
Thanks Bob and Peter, I really misspelled the method name.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: De-serialization
 
Similar Threads
De-Serialization is returning Null values
Serialization in K&B
Problem with read-write methods in Serialization
defaultReadObject() required?
A question regarding defaultXxxObject()