Results 1 to 6 of 6
- 06-13-2012, 07:36 PM #1
Member
- Join Date
- Jun 2012
- Posts
- 12
- Rep Power
- 0
Putting multiple objects in a file
I need to put several colors and a few dozen ints into a file. How would I save them into that file? I know how to put things in a file, but how would I separate the objects, and how would I be able to access each one individually once the program is being used? Thank you for any help.
- 06-13-2012, 07:43 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,604
- Rep Power
- 5
Re: Putting multiple objects in a file
You could write the values of the objects to file in a pre-dermined file format of your choice, or you could serialize the objects into the file:
Discover the secrets of the Java Serialization API
- 06-13-2012, 08:19 PM #3
Member
- Join Date
- Jun 2012
- Posts
- 12
- Rep Power
- 0
Re: Putting multiple objects in a file
I'm really confused now. That didn't make much sense to me.
-
Re: Putting multiple objects in a file
The article looks pretty detailed to me. What *specifically* are you confused about?
- 06-13-2012, 08:47 PM #5
Member
- Join Date
- Jun 2012
- Posts
- 12
- Rep Power
- 0
Re: Putting multiple objects in a file
Well. What exactly is serialization? How do I read the data after it is written? How do I choose what portion to read?
-
Re: Putting multiple objects in a file
Serialization is one way that Java allows you to write objects to and read objects from a file (or other binary form). It's a bit much to explain in a forum, and you're much better off reading up about it from a tutorial (at least to start with) and then asking your specific questions about what you don't understand in the tutorial here. If the above tutorial doesn't work well for you, please check out others, such as this one, since much has been written on this subject.
Similar Threads
-
Reading input from a .txt file and then putting it into a array
By BetaDave1877 in forum New To JavaReplies: 2Last Post: 04-16-2012, 12:56 AM -
Putting multiple outputs into one JOptionPane Dialog Box?
By pwe9109 in forum New To JavaReplies: 8Last Post: 09-12-2011, 01:43 PM -
Serialization and Deserialization of multiple objects from single file
By hanx in forum Advanced JavaReplies: 3Last Post: 02-28-2011, 05:09 PM -
Retrieving data from text file and putting it into comboboxes
By the reporter in forum AWT / SwingReplies: 3Last Post: 06-02-2010, 06:58 PM -
how to deserialize multiple objects in a file
By xcallmejudasx in forum Advanced JavaReplies: 11Last Post: 12-16-2008, 05:29 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks