Results 1 to 1 of 1
Thread: Tips for saving?
- 04-29-2012, 09:57 PM #1
Senior Member
- Join Date
- Feb 2012
- Posts
- 219
- Rep Power
- 2
Tips for saving?
I recently decided to write an ATM simulator, and was wondering what the best method is to save the People objects I have created. They are in a linked list structure which I would also like to retain. Here is what I currently have to save and open the files.
Java Code:public static void Save(Node<Person> head) throws IOException { FileOutputStream out = new FileOutputStream("save"); ObjectOutputStream Objout = new ObjectOutputStream(out); //Let's write all the objects in the linked list to a file. Node<Person> cursor; for(cursor = head; cursor != null; cursor = cursor.returnforward() ) { Objout.writeObject(cursor.returnData()); } }
and to open
It doesn't seem to throw any errors, but it doesn't load the saved files. Any help is appreciated.Java Code:public static void Open() throws IOException, ClassNotFoundException { FileInputStream in = new FileInputStream("save"); ObjectInputStream Objin = new ObjectInputStream(in); Person obj = (Person)Objin.readObject(); int id = Objin.read(); AddToList(obj); } }
Similar Threads
-
Hey need some quick tips
By Phyxed in forum New To JavaReplies: 1Last Post: 02-23-2011, 02:09 AM -
Recursion tips?
By MojoeMAN in forum New To JavaReplies: 1Last Post: 01-02-2011, 05:36 AM -
Tips needed
By adz06 in forum New To JavaReplies: 5Last Post: 12-07-2009, 01:35 AM -
need some derby tips:
By kulangotski in forum Advanced JavaReplies: 4Last Post: 03-09-2009, 05:09 PM -
Need some tips.
By PVL268 in forum New To JavaReplies: 4Last Post: 02-27-2009, 02:37 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks