import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
class SerializationDemo {
public static void main(String[] args) {
try {
Student s1 = new Student(23, "Ramakesh");
FileOutputStream fout = new FileOutputStream("student.txt");
ObjectOutputStream out = new ObjectOutputStream(fout);
out.writeObject(s1);
out.flush();
// closing the stream
out.close();
System.out.println("State of object is successfully saved");
} catch (Exception e) {
e.printStackTrace();
}
}
}