File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serialization in java

 
Bandita Patel
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When should we go for Serialization in a Java project? please give some example.Is it possible to serialize static variables? if yes then how & if no then why? please explain it...
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Serialization should be used with caution. If your class changes frequently, you will get into serious trouble reading old serialized files. So, in general an xml format or a database is the better choice.

as for the static classes --> http://www.coderanch.com/t/405828/Beginning-Java/java/we-Serialize-Static-Variable
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that "serialization" is a process, and it can be implemented in different ways. Out of the box, Java offers binary serialization (via the Object[In|Out]putStream classes) and XML serialization for JavaBean objects (via the XML[De|En]coder classes). As Sebastian mentioned, the binary format is brittle in the face of class changes, and may break when used between different JVM versions; so the XML format is a better choice these days (and is amenable to changes by non-JVM processes, which may or may not be useful in your circumstances).
 
Jim Hoglund
Ranch Hand
Posts: 525
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a bandita wrote:When should we go for Serialization in a Java project? ...

What do you mean by "go for", what kind of objects do you want to
serialize and for what purpose?

Jim ... ...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic