Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.io.ObjectInputStream;
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author themuser
- */
- public class DeserializeMyClassToBePersisted {
- public static void main(String [] args) {
- String filename = "class.ser";
- if(args.length > 0) {
- filename = args[0];
- }
- // Deserialize the previously saved
- // PersistentTime object instance.
- MyClassToBePersisted myClass = null;
- FileInputStream fis = null;
- ObjectInputStream in = null;
- try {
- fis = new FileInputStream(filename);
- in = new ObjectInputStream(fis);
- myClass = (MyClassToBePersisted)in.readObject();
- in.close();
- } catch(IOException ex) {
- ex.printStackTrace();
- } catch(ClassNotFoundException ex) {
- ex.printStackTrace();
- }
- // print out restored myClass
- System.out.println("BEFORE : " + myClass);
- // print out the current myClass
- System.out.println("AFTER : " + new MyClassToBePersisted());
- }
- }
Add Comment
Please, Sign In to add comment