// Reading serializable objects from file

import java.io.File;
import java.io.FileInputStream;
import java.io.ObjectInputStream;

public class StudentRead {
    public static void main(String[] args) throws Exception {
        ObjectInputStream in = new ObjectInputStream(new FileInputStream(new File("student.ser")));
      
        Student student = (Student)in.readObject();
        System.out.println(student.getName());
      
        student = (Student)in.readObject();
        System.out.println(student.getName());
    }
}

Comments

Popular posts from this blog

Zeller's Congruence

Property Event-Delegation

Method with variable arguments