Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

multiple entries for a key in Preferences

Thread view: 
Rajarshi Guha - 10 Nov 2005 01:04 GMT
Hi, I have an app in which I'd like to keep track of multiple user
specified directories. In the past I have used a dot file in the users
home directory and simply parsed that.

However I'd like to use the Preferences API but I'm not sure how I can
handle this situation.

So for example I need to keep track of directories DIRA, DIRB and DIRC.

All of them would correspond to a dirEntries

So I could do something like:

Preferences prefs =
Preferences.userRoot().node("/net/guha/apps/cdkdesc/dirEntries") ;

However if I now go to do

prefs.put("Entry", "DIRA");

I can't put in the others using the same key.

One possibility I thought of using the hash() method for a given String,
but I'm not sure that will always be unique.

The only other approach I can think of is to make the key and the value
the same.

Are there any better approaches to this problem?

Thanks,
Rajarshi
Rhino - 10 Nov 2005 04:58 GMT
> Hi, I have an app in which I'd like to keep track of multiple user
> specified directories. In the past I have used a dot file in the users
[quoted text clipped - 28 lines]
> Thanks,
> Rajarshi

I had a comparable situation where I wanted to store an unknown number of
Strings of variable length in a single preference key. I simply concatenated
all of the Strings together into a single String, separated by a delimiter
of my choosing, then stuffed the concatenation String into a preference key.
When I retrieved the key again, I had to parse the values but that was easy
since I knew what delimiter I had placed after each of the Strings within
the concatenation.

I'm not saying that's the BEST way to handle the problem - someone else may
suggest something better - but it certainly worked well for me.

Rhino


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.