Results 1 to 4 of 4
Thread: Saving prefs
- 12-14-2010, 03:57 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 49
- Rep Power
- 0
Saving prefs
I've got an application that can launch n threads, each with its own settings. I'm passing values to these threads through a serializable object called Properties that contains public variables.
Right now, I'm saving my application preferences by adding all Properties objects to a collection and then writing them to a file. However, I'm starting to wonder whether or not I should be using java.util.prefs.Preferences and saving my preferences to an XML file instead.
Reading objects from a file is simple and straightforward when it comes to starting the threads, but modifying and saving the collection of objects is a pain. Should I switch to java.util.prefs.Preferences or not?
- 12-14-2010, 04:12 PM #2
- 12-14-2010, 04:15 PM #3
Member
- Join Date
- Dec 2008
- Posts
- 49
- Rep Power
- 0
Is it bad practice to save preferences as serializable objects written to a file? It's fast and easy, but the XML option still seems cleaner to me.
- 12-15-2010, 07:25 PM #4
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
If you use Preferences, they may get persisted independent of the xml import/export feature. On unix systems, they'll get written into the user's home directory in a hidden .java directory. On Windows, they'll get persisted to the Window's registry. This potential side effect may be of concern if all you're trying to do is read/write xml files.
Similar Threads
-
Hi! Saving data??
By Gahstanz in forum New To JavaReplies: 1Last Post: 06-29-2010, 06:29 AM -
Saving JTextArea to .txt
By AwesomeStorm in forum New To JavaReplies: 8Last Post: 05-29-2010, 07:14 AM -
Saving JFrame
By jralexander in forum New To JavaReplies: 7Last Post: 12-03-2008, 09:19 PM -
Saving changes done through a program
By xcallmejudasx in forum New To JavaReplies: 0Last Post: 12-02-2008, 04:53 PM -
Saving Variables
By Fish in forum New To JavaReplies: 6Last Post: 06-25-2007, 08:20 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks