Reading all related keys from a properties file
I have in my propeties file, keys the following way:
FIRST_DATASOURCE=COM.XYZ.ABCSERVER.JDBC1
SECOND_DATASOURCE=COM.ABC.SERVER2.JDBC1
FIRST_DATASOURCE=COM.123.SERVER3.JDBC3
What is the solution to read all the keys wit _DATASOURCE and return as a string array?
Thanks in advance.
[316 byte] By [
KSNSa] at [2007-11-27 0:50:38]

hI KAJBJ
sORRY FOR the typo error. The code is as follows:
FIRST_DATASOURCE=COM.XYZ.ABCSERVER.JDBC1
SECOND_DATASOURCE=COM.ABC.SERVER2.JDBC2
THIRD_DATASOURCE=COM.123.SERVER3.JDBC3
Clarification:
Is there any method available in ResourceBundle class to read the keys and get a String[ ]?
Thanks
KSNSa at 2007-7-11 23:20:51 >

> Clarification:> Is there any method available in ResourceBundle class> to read the keys and get a String[ ]?No, read the data, add it to e.g an ArrayList<String>, and call toArray when you are done reading.Kaj
kajbja at 2007-7-11 23:20:51 >

Thanks kajbj..The problem here is the datasources are added from time to time and the program should pick-up dynamically.If I hardcode for the existing available datasources, how can it handle for the future?Appreciate your thoughts.
KSNSa at 2007-7-11 23:20:51 >

> Appreciate your thoughts.Depends on what more you have in that file. You can get all keys, do a substring search and see if they match a certain pattern, then get the values for those that match.Kaj
kajbja at 2007-7-11 23:20:51 >

> Thanks kajbj..
>
> The problem here is the datasources are added from
> time to time and the program should pick-up
> dynamically.
>
> If I hardcode for the existing available datasources,
> how can it handle for the future?
>
> Appreciate your thoughts.
Many answer can be found by reading API
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Properties.html#propertyNames()
rym82a at 2007-7-11 23:20:51 >
