wood burning stoves*
The moose likes Java in General and the fly likes Serialization in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Serialization in java" Watch "Serialization in java" New topic
Author

Serialization in java

Bandita Patel
Greenhorn

Joined: Mar 23, 2010
Posts: 25
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

Joined: Feb 23, 2009
Posts: 1183
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


JDBCSupport - An easy to use, light-weight JDBC framework -
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
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).


Ping & DNS - my free Android networking tools app
Jim Hoglund
Ranch Hand

Joined: Jan 09, 2008
Posts: 525
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 ... ...


BEE MBA PMP SCJP-6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Serialization in java