aspose file tools*
The moose likes Java in General and the fly likes Saving Program Data... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Saving Program Data..." Watch "Saving Program Data..." New topic
Author

Saving Program Data...

Martin Clifford
Greenhorn

Joined: Dec 02, 2002
Posts: 23
Hello everyone!
I'm probably barely above beginner level, if that, but I am trying to write a program in which the user will enter some data (method unknown), and I want to store this information (at least during runtime), inside one of the many collections classes. That I can do. What I am unfamiliar with is how you go about SAVING that collection to a file, and also how you would LOAD it from the file.
I have a strong suspicion (for some reason that word looks mispelled), that it has something to do with serialization, but I am unsure right now. Does anyone have any helpful hints, or could anyone point me in the right direction to get started? Don't want solutions, just gentle nudges so I can start on the right path )
Thanks in advance!


Martin
Peter Kristensson
Ranch Hand

Joined: Jul 02, 2001
Posts: 118
Hiya.
You can use the ObjectInputStream and ObjectOutputStream in the java.io package to do this. Please note that this code hasn't been tested.
Writing:

and for reading:

This is possible due to the fact that all classes that implements the Collection interface are Serializable if I remember correclty. Take into consideration however that the things that you put in you Collection has to be serializable also.
/Peter
[ January 03, 2003: Message edited by: Peter Kristensson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Saving Program Data...
 
Similar Threads
A question regarding saving jpgs into text files.
saving the data into database
working with pdf.... in java j2ee
gettng joptionpane text
read text file and save data into database