This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
All it will do is simply serialized and de-serialized. But, The serialized object, where will be stored? If it is jvm, then how can I store data permanently in serialized mode. Like for example, consider a simple game. Game have a feature like you can save the current level and you can shut down the game. When you open the same again(after so many days), it'll start from the level where you saved last time not from the beginning level. How can you achieve this. In that type of case, should we save that data into DB instead of doing serialize? I mean, serialization is volatile, like until and unless program shutdown serialization works after that it'll not right?(I think yes, exactly don't know)
The serialized objects are stored in the file "nameStore", like the code specifies. Where that file is created depends on what the default directory is when this code is run. If you want control over the directory, use absolute paths instead of relative paths.
serialization is volatile, like until and unless program shutdown serialization works after that it'll not right?
I'm not sure what you're trying to say here, but serialization is frequently used to store data for later use during a future invocation of the JVM. So I think your understanding is wrong.
Personally, I don't like to use binary serialization, I prefer XML serialization using the java.beans.XMLEncoder and XMLDecoder classes. For storing game status it should be easy to meet the requirement that the serialized classes obey JavaBeans conventions.
You should also check out the java.util.prefs package. For a desktop app that may be a better fit than serialization - for example, you don't have to worry about files, and where they might get stored.
That causes the code to create a new file (possibly overwriting an existing file) named "nameStore", in the current directory (the directory you're running from). Later code causes the program to read from that same file, to deserialize the object. You can read up on FileOutputStream, and input and output streams in general, to understand better how this works. A good place to start is the Java Tutorial on Basic I/O.
Joined: Mar 05, 2008
Curses - I've been Ulfed! ;)
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com