Objects Files I/O

It is possible to store objects just as easy as we can store primitive data values !!

Using ObjectOutputStream and ObjectInputStream we can save and load the state of an object to a file

However if we want to save object we must have a given class we must have a maker interface. An interface that has no field or methods. It can be serializable or Clonnable.

Know you might be asking what’s sterilization/ deserialization. ?

Well , Serialization is a mechanism of converting the state of an object into a byte stream .

Meanwhile ,Deseialization is the reverse process where the byte stream is used to persist the object.

Just remember !!! IF we want to save objects from a given class . The declaration must include the phrase : IMPLEMENTS SERIALIZABLE

Creating an object :

Saving an object to a file

Output from saving an object to a file :

Reading the saved object from a file

Output from Reading the object :

Leave a comment