Discussion on:
View:
Show:
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.
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.
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
Javin
Top 10 Java Serialization Interview Question
- Keyboard Shortcuts:
- Prev
- Next
- Toggle









































