Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-04-2009, 11:24 PM
Member
 
Join Date: Jan 2009
Posts: 4
Rep Power: 0
geeeeky.girl is on a distinguished road
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-05-2009 at 12:06 AM.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
storing exel data to access database sijokunnappilly Advanced Java 1 10-30-2008 08:59 AM
parsing/storing large text data hkansal New To Java 4 10-19-2008 07:34 PM
problems about storing binary data to mysql db using PreparedStatement xiechao New To Java 0 04-22-2008 12:57 PM
Storing data permanently shaungoater New To Java 2 03-10-2008 05:18 PM
Storing Data Khorod New To Java 1 08-03-2007 06:48 AM


All times are GMT +2. The time now is 07:19 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org