• Post Reply Bookmark Topic Watch Topic
  • New Topic

Serialization  RSS feed

 
anita dhar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i am not able to understand how serialzation works and where we are using this concept
 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi anita,
I can clear your doubt to some extent,below shown is a link.

http://www.oreilly.com/catalog/javarmi/chapter/ch10.html

 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Serialization is preferred when you want to persist the state of the object.

That means saving the state of the object into a permanent storage. Say, into a file in the disk.

State of the Object means the values of instance variables of the object you are serializing excluding the variables which are declared as 'transient'.

  • Serialization - process of storing the state of object into a permanent stoage
  • Deserialization - reverse process; process of restoring the state of the object from the permanent storage


  • Important points to note:
    ------------------------
    (a) Its mainly used when you do with RMI - Remote Method Invocation wherein you are supposed to pass the object into the network - over wires (streamlined version). Basically the objects should be of serializable in nature.
    (b) The class whose instances gonna be serialized - should implement the interface java.io.Serializable.
    (c) You can do the serialization and deserialization through the read() and write() methods.

    Hope it clears now.

    There are many more aspects with respect to serialization, which you can read it in tutorials, articles later. Just google it.
    [ May 24, 2007: Message edited by: Raghavan Muthu ]
     
    Raghavan Muthu
    Ranch Hand
    Posts: 3389
    Mac MySQL Database Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    This link gives an explanation of Serialization with a good example.

    It works good for Java SE 1.4.2. Try this.

    Good luck.
     
    Stan James
    (instanceof Sidekick)
    Ranch Hand
    Posts: 8791
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I'd modify Raghavan's explanation a bit to replace "permanent storage" with "any stream". The stream can go to or from anywhere ... disk, a String in memory, over the network, anything else you can imagine.

    The term can refer to the general problem of sending data structures over a stream. We can use the same words - serialize and deserialize - for writing object state out to XML, JSON, CSV or some proprietary format and reading it back.
     
    Raghavan Muthu
    Ranch Hand
    Posts: 3389
    Mac MySQL Database Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for the correction Stan James.

    Yes, you are right
     
    Consider Paul's rocket mass heater.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!