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