2020. 2. 29. 17:47ㆍ카테고리 없음
Java Tutorial Pdf Download
.Serialization in Java is a mechanism of writing the state of an object into a byte-stream. It is mainly used in Hibernate, RMI, JPA, EJB and JMS technologies.The reverse operation of serialization is called deserialization where byte-stream is converted into an object. The serialization and deserialization process is platform-independent, it means you can serialize an object in a platform and deserialize in different platform.For serializing the object, we call the writeObject method ObjectOutputStream, and for deserialization we call the readObject method of ObjectInputStream class.We must have to implement the Serializable interface for serializing the object. Advantages of Java SerializationIt is mainly used to travel object's state on the network (which is known as marshaling). Java.io.Serializable interfaceSerializable is a marker interface (has no data member and method). It is used to 'mark' Java classes so that the objects of these classes may get a certain capability. The Cloneable and Remote are also marker interfaces.It must be implemented by the class whose object you want to persist.The String class and all the wrapper classes implement the java.io.Serializable interface by default.Let's see the example given below.