Results 1 to 2 of 2
Thread: What is Serializing good for?
- 02-10-2013, 03:08 PM #1Member
- Join Date
- Feb 2013
- Rep Power
What is Serializing good for?
I'm currently reading through the SCJP 6 book and have reached Chapter 6, specifically, Serializing. For me, to grasp and understand something to its' fullest (relatively speaking, of course), I need to understand what it is good for, why it is used, and most importantly, when.
If you had used Serializing, could you tell me why you did so, and what it was for? I understand that you can save the state of an Object on the file system, I just don't understand where it could be used. Like saving a game, or saving properties to a file, or..?
Thanks in advance,
- 02-10-2013, 07:22 PM #2Senior Member
- Join Date
- Oct 2011
- Rep Power
Re: What is Serializing good for?
there are some really good sites that clarifies this, mostly the Oracle API site for Java itself. It can be found here: Serializable (Java Platform SE 7 )
To understand when to use it, you have to understand what it is.
Serialization is a common term for taking an object and turning it into a series of bits, or an ordered stream of bytes. These can later on be read and deserialized into an identical clone of the object that was serialized. Just by thinking of this, I think you can come up with many good usages for this, such as storing information in a file to be sent to another system, or to send something over a network link.
In Java, you use the interface Serializable to make this happen. If you create a class that has to be able to be serialized, you just implement this interface. The good thing in Java, as far as I has understood is that this is done completely by the JVM and thus makes it possible to transfer the serialized object to any given system that has a JVM that can deserialize the object.
To use this, take a look at ObjectInputStream and ObjectOutputStream classes.
I hope this helps!
- By kev670 in forum New To JavaReplies: 1Last Post: 04-03-2011, 07:05 PM
- By shashanksworld in forum New To JavaReplies: 7Last Post: 03-29-2010, 04:47 PM
- By MrFreeweed in forum IntroductionsReplies: 3Last Post: 12-11-2009, 04:32 PM
- By MamboBanda in forum New To JavaReplies: 1Last Post: 08-12-2008, 12:15 AM