Win a copy of Functional Reactive Programming this week in the Other Languages forum!
    Bookmark Topic Watch Topic
  • New Topic

question reg. Serialization process

 
Poornachandran R
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hai,
An article from Sun reg the same can be found here
http://developer.java.sun.com/developer/technicalArticles/Programming/serialization/
I have some doubts:
public class A implements Serializable {
private void writeObject(ObjectOutputStream out) throws IOException
{
out.defaultWriteObject();
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
in.defaultReadObject();
}
}
In the above example,
1) Can I give the following line just after line of the method writeObject.
out = new ObjectOutputStream(fos); // assume fos - FileOutputStream.
2) What is the difference between this approach and Externalizable ? Because, in both the approaches we define our own way of how Object is written and read.
Poornachandran
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Poornachandran,
Welcome to JavaRanch, the absolute best site on the www for Java information. We don't have many rules around here, but we do have one. Please change your display name to a first and last name to comply with the JavaRanch Naming Policy. You can change it here. Thank you for your cooperation.
Also, please do not cross post topics. Choose just forum per topic.
Closing this. Please respond
here
 
    Bookmark Topic Watch Topic
  • New Topic