How to read object from a file in java

In this post, we will see how to read object from file in java. In last post, we have already seen how to write object to a file and created employee.ser , now in this post, we are going to read same file and retrieve back Employee object.

Java Serialization Tutorial:

Reading object from file using ObjectInputStream may be referred as Deserialization.

Lets take an example:
Create same as last example in src->org.arpit.java2blog

Create in src->org.arpit.java2blog

3.Run it:

When you run above and you will get following output:

These are some simple steps to read object from file. If you want to go through some complex scenario you can go through Serialization in java

Add Comment