Core Java Concepts:
Serialization
Serialization is defined as the process of converting an object into a sequence of bytes that can persist in a database or can be sent through streams.
Serialization saves the state of objects for recreation without having to reprocess them on different platforms.
Serialization is useful for storing, Transmitting the state of an object, and also Cloning an object without overriding the clone.
Create an ObjectOutputStream with a FileOutputStream, to store a serialized object in a file.
FileOutputStream is used to write binary data to a file while ObjectOutputStream is used to convert Java Object to a sequence of bytes and write it to an OutputStream.
Concept of Serialize:
File: SerializationClass.java
Output:
Deserialization
Deserialization is defined as the opposite or reverse process of creating an object from a sequence of bytes.
Create an ObjectInputStream with a FileInputStream, to re-create an object from a file.
FileInputStream is used to read binary data from files while ObjectInputStream is used to read a sequence of bytes from an InputStream and reconstructs Java Object from that data.
Concept of Deserialize:
file:DeserializationClass.java
Output: