Results 1 to 1 of 1
  1. #1
    geeeeky.girl is offline Member
    Join Date
    Jan 2009
    Posts
    4
    Rep Power
    0

    Default Storing and Retrieving Data Using XStream & xml Files

    Hi all!

    I'm very frustrated, I've spent hours, probably an entire day in all, trying to find an extremely concise example of how to store and retrieve data using XStream / XML files. Before answering, please read on, and please keep in mind that I'm, relatively speaking, a beginner or advanced beginner.

    Let's say I have an address book which contains a "Person.java" class (String name, String address, String phoneNumber) and an "AddressBook.java" class containing an ArrayList<Person> and possibly other fields. I also have a main or test class...

    I want to save everything in the address book in an xml file using XStream and, more importantly, be able to retrieve the data.

    First Question: WHERE?
    I think what I want to do is create a save() and load() method (is that right?), however I don't know where to put them and how to use them! In the AddressBook class? Shall I call it everytime there is a change so that any changes are automatically saved? (in all setters and constructors)? What's the best way to organize this?

    Second Question: WANTED: SIMPLE, CLEAR, CONCISE CODE WITH SIMPLE, CLEAR, CONCISE COMMENTS AND NO ADDITIONAL EXPLANATION, I BEG YOU!!!
    I actually don't want an answer, code tells me much more than lengthy explanations. What I would like is working code that I could cut, paste and test for the above (save() and load() or whatever/however is the best way to do this.). The shorter, the better.

    Thank you so much, and I really look forward to hearing from you.

    Desperately yours,

    geeeeky.girl
    Last edited by geeeeky.girl; 01-04-2009 at 11:06 PM.

Similar Threads

  1. storing exel data to access database
    By sijokunnappilly in forum Advanced Java
    Replies: 1
    Last Post: 10-30-2008, 07:59 AM
  2. parsing/storing large text data
    By hkansal in forum New To Java
    Replies: 4
    Last Post: 10-19-2008, 06:34 PM
  3. Replies: 0
    Last Post: 04-22-2008, 11:57 AM
  4. Storing data permanently
    By shaungoater in forum New To Java
    Replies: 2
    Last Post: 03-10-2008, 04:18 PM
  5. Storing Data
    By Khorod in forum New To Java
    Replies: 1
    Last Post: 08-03-2007, 05:48 AM

Posting Permissions

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