Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By Fubarable

Thread: Putting multiple objects in a file

  1. #1
    DFTBA is offline Member
    Join Date
    Jun 2012
    Posts
    12
    Rep Power
    0

    Default 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.

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    6

    Default 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

  3. #3
    DFTBA is offline Member
    Join Date
    Jun 2012
    Posts
    12
    Rep Power
    0

    Default Re: Putting multiple objects in a file

    I'm really confused now. That didn't make much sense to me.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Putting multiple objects in a file

    The article looks pretty detailed to me. What *specifically* are you confused about?

  5. #5
    DFTBA is offline Member
    Join Date
    Jun 2012
    Posts
    12
    Rep Power
    0

    Default 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?

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default 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.
    DarrylBurke likes this.

Similar Threads

  1. Replies: 2
    Last Post: 04-16-2012, 12:56 AM
  2. Replies: 8
    Last Post: 09-12-2011, 01:43 PM
  3. Replies: 3
    Last Post: 02-28-2011, 05:09 PM
  4. Replies: 3
    Last Post: 06-02-2010, 06:58 PM
  5. how to deserialize multiple objects in a file
    By xcallmejudasx in forum Advanced Java
    Replies: 11
    Last Post: 12-16-2008, 05:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •