Discussion on:

5
Comments

Join the conversation!

Follow via:
RSS
Email Alert
0 Votes
+ -
caminho
mtuliobr@... 19th Feb 2007
segredo de estado
0 Votes
+ -
It should be mentioned that there are two "secret" methods named readResolve and writeResolve. If you add any of these to a class that implements Serializable you will be given similar control as described for Externalize.writeExternal and Externalize.readExternal.
How can I descerialize an object in following cases:

1.Let I have a class

public class Employee implements Serializable{
String name;
int age;
public Employee(){
name="abc";
age = 20;
}
//with getter and setter

}

Now I have serialized it.

After that I have added another instace member called
String dob ;

Now When I trying to descerialize the Previous Object
I am getting Error like SerialVersionUid mismatch.

How can I descerialize the previous Object with that class.
0 Votes
+ -
TO Rajnish
RaviMalik 17th Apr 2011
You can define your own serialVersionUID. Refer to http://java.sun.com/developer/technicalArticles/Programming/serialization/ for more details
good discussion I think performance should be the main reason while deciding on Externalizable over serializable but some time flexibility and control also plays important role.

Javin
Top 10 Java Serialization Interview Question
Keyboard Shortcuts:
Prev
Next
Toggle
Join the conversation
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.