File size: 779 Bytes
c574d3a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import java.io.*;
class Deserialization {
public static void main(String args[]) throws IOException {
ObjectInputStream in = null;
FileInputStream fin = null;
try {
// Reading the object file
fin = new FileInputStream("f.txt");
// Creating stream to read the object
in = new ObjectInputStream(fin);
Student s = (Student) in.readObject();
// printing the data of the serialized object
System.out.println(s.rollNumber + " " + s.name);
} catch (Exception e) {
System.out.println(e);
} finally {
// closing the stream
in.close();
// closing the file input stream
fin.close();
}
}
}
|