File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Read duplicate keys from properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Read duplicate keys from properties file" Watch "Read duplicate keys from properties file" New topic

Read duplicate keys from properties file

Robin Sharma
Ranch Hand

Joined: Aug 24, 2005
Posts: 76
How to read duplicate keys from a properties file.


There is always a bug :-)
ak pillai
Ranch Hand

Joined: Feb 11, 2006
Posts: 288
The properies file cannot have duplicate keys. you can have array of values returned for a supplied key.

the above key1 can return array of values.

java j2ee job interview questions with answers | Learn the core concepts and the key areas
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
If you really want to do something along these lines, you'll have to write the code to read (and perhaps write) the "properties" file yourself. This can be fairly simple, actually. And you'd need some sort of data structure which allows multiple values for a given key - Properties doesn't. You may want to look at org.apache.commons.collections.MultiMap for example. Or use an array for the value, as ak suggests.
[ March 13, 2006: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: Read duplicate keys from properties file
jQuery in Action, 3rd edition