Deserialization


import java.io.FileInputStream;
font color="#7f0055">import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;

public class DeserializationDemo {

    public static void main(String[] argsthrows FileNotFoundException, IOException, ClassNotFoundException {
        Student st;
        FileInputStream fInput = new FileInputStream("E:/temp/student.ser");
        ObjectInputStream obIn = new ObjectInputStream(fInput);
        st = (StudentobIn.readObject();
        obIn.close();
        fInput.close();
        System.out.println("Deserialized Student...");
        System.out.println("Name: " + st.name);
        System.out.println("Roll No: " + st.roll_no);
        System.out.println("Marks: " + st.marks);
    }
}

Output:
Deserialized