Serialization in java example
- when serialization is required in java
- when to use serialization in java
- why do we need serialization in java
- java сериализация десериализация
Serialization in java w3schools...
Serialization in java
Serialization and Deserialization in Java with Example
Serialization is a mechanism of converting the state of an object into a byte stream. Deserialization is the reverse process where the byte stream is used to recreate the actual Java object in memory.
This mechanism is used to persist the object.
The byte stream created is platform independent.
So, the object serialized on one platform can be deserialized on a different platform. To make a Java object serializable we implement the java.io.Serializable interface. The ObjectOutputStream class contains writeObject() method for serializing an Object.
throws IOException
The ObjectInputStream class contains readObject() method for deserializing an object.
throws IOException,
ClassNotFoundException
Advantages of Serialization
- To save/persist state of an object.
- To travel an object across a network.
Only the objects of those classes can be serialized which are implementing
- how serialization works in java
- why serialization required