Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Test
- {
- public static void main(String[] args)
- {
- Object object1 = null;
- try
- {
- // Reading the object from a file
- FileInputStream file = new FileInputStream(filename);
- ObjectInputStream in = new ObjectInputStream(file);
- // Method for deserialization of object
- // We have to cast the object read from the byte stream to a Dog
- object1 = (Dog)in.readObject();
- in.close();
- file.close();
- System.out.println("Object has been deserialized ");
- System.out.println("a = " + object1.a);
- System.out.println("b = " + object1.b);
- }
- catch(IOException ex)
- {
- System.out.println("IOException is caught");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement