Guest User

Untitled

a guest
Nov 19th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import java.io.*;
  2. public class DeserializeDemo {
  3. public static void main(String [] args) {
  4. Student s = null;
  5. try {
  6. FileInputStream fileIn = new FileInputStream("/tmp/student.ser");
  7. ObjectInputStream in = new ObjectInputStream(fileIn);
  8. s = (Stduent) in.readObject();
  9. in.close();
  10. fileIn.close();
  11. } catch (IOException i) {
  12. i.printStackTrace();
  13. return;
  14. } catch (ClassNotFoundException c) {
  15. System.out.println("Student class not found");
  16. c.printStackTrace();
  17. return;
  18. }
  19. System.out.println("Deserialized Student...");
  20. System.out.println("Name: " + s.name);
  21. System.out.println("Address: " + s.address);
  22. System.out.println("Number: " + e.number);
  23. }
  24. }
Add Comment
Please, Sign In to add comment