Hello everyone,


I am wondering how to use java.util.Properties to get the corresponding value of a specific key whose corresponding value is an array, and I am also wondering how to express/format an array in a properties file. For example, I have a key "friends" whose corresponding value is a String Array {"Tom", "Jerry", "Cat", "Mouse"}. When key "friends" is provided, the corresponding value which I want to get is the String array {"Tom", "Jerry", "Cat", "Mouse"}.


Thanks in advance,
George

I'm not sure I understand completely...So correct me if I'm wrong, when the user enters a specific key, such as "friends", you want to "spit" out the array corresponding to that array.

Thanks server_crash,

I'm not sure I understand completely...So correct me if I'm wrong, when the user enters a specific key, such as "friends", you want to "spit" out the array corresponding to that array.

My question is, when the user enters a specific key of a property, such as "friends", I want to retrieve a String array {"Tom", "Jerry", "Cat", "Mouse"} from a Java property file. I am also wondering how to format a String array in a Java property file.


regards,
George

properties consist of simple key-value pairs with 1 value per key.
You seem to want multiple values per key which is not directly supported.

There are ways around this but it would be far better to take another mechanism like XML to store your data.

Thanks jwenting,

properties consist of simple key-value pairs with 1 value per key.
You seem to want multiple values per key which is not directly supported.

There are ways around this but it would be far better to take another mechanism like XML to store your data.

Your idea of using XML based format is great. I am using JDK 1.3 and I am wondering whether there exists some SDKs or tools that supports XML based property files. Are there any online tutorials or source codes?


regards,
George

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.