Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class DeserializeDemo {
- public static void main(String [] args) {
- Student s = null;
- try {
- FileInputStream fileIn = new FileInputStream("/tmp/student.ser");
- ObjectInputStream in = new ObjectInputStream(fileIn);
- s = (Stduent) in.readObject();
- in.close();
- fileIn.close();
- } catch (IOException i) {
- i.printStackTrace();
- return;
- } catch (ClassNotFoundException c) {
- System.out.println("Student class not found");
- c.printStackTrace();
- return;
- }
- System.out.println("Deserialized Student...");
- System.out.println("Name: " + s.name);
- System.out.println("Address: " + s.address);
- System.out.println("Number: " + e.number);
- }
- }
Add Comment
Please, Sign In to add comment