an alternative to properties files?
Hello!
I want to store and retrieve in/from a file some parameters. The problem is that I have multiple values for the same key
for example
key name=db
values for this key: db1,db2,db3
More, at some point
I need some kind of association of the following type
[key1,key2] -> value1
[key1,key3] -> value 2
.....
etc
Is some way to model this using a properties file or some kind of similar built-in mechanism (without having to parse a text file)?
Thanks
Sorin
Could have those multiple values on the one line, and delimited by something. Nasty but it works. Or you could use XML
Hang on, you say you have multiple values for one key, but your example is the other way round - multiple keys for one value. Which is it?
I have both cases, as written:
1 key and multiple values
multiple keys and 1 value
Yeah go to XML and just DOM parse it...
it'll handle the 1-to-many; and many-to-1 relationships ok.
properties presumes there is a unique key.
Or even simpler, perhaps. Use something like Apache Digester or Spring's IoC container to configure a bean. Might be a bit heavyweight for your needs, though