// 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());
}
}
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
Post a Comment
Post Your Valuable Comments