View RSS Feed

Java Socket

Overview of Object Serialization

Rate this Entry
by , 04-25-2012 at 10:14 PM (614 Views)
Object serialization is that mechanism which is considered useful in all programs which save objectís state to the file and then reads objects for reconstruction of the state of program, or using the sockets to send object at the network. Class serialization could be done very easily by using class implement interface. It is marker interface which has no methods to be implemented. This is used for informing the JVM (Java Virtual Machine) which one wants an object to get serialized.

Two main classes used to write or read objects, to stream:

ObjectInputStream & ObjectOutputStream

ObjectOutputStream gives a method called writeObject to write object to output stream. On the other hand, ObjectInputStream gives a method known as readObject so that from input stream an object could be read. Important thing is that objects shall be serialized that are used by the objects. This actually means that Serializable interface shall be implemented by the classes.

Submit "Overview of Object Serialization" to Facebook Submit "Overview of Object Serialization" to Digg Submit "Overview of Object Serialization" to Submit "Overview of Object Serialization" to StumbleUpon Submit "Overview of Object Serialization" to Google