Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

Doubt in .properties file reading

Thread view: 
singh.inderjeet@gmail.com - 17 Apr 2006 08:13 GMT
Hi All,

I have a doubt regarding properties file from which I am reading some
key-values. Now I have few different keys (4-5) having same value .e.g.
key1=value1
key2=value1
key3=value1
key4=value1
key5=value1

Now I need to read these keys from different places and I also need to
update the value to say 'value2' for all the keys e.g.

key1=value2
key2=value2
key3=value2
key4=value2
key5=value2

Now, since i need to update the values of all the keys, I am thinking
of having another key-value pair (e.g. key=value1) in the same property
file, and using the value of this key as value for all the keys
displayed above. So that when I update the value of this key (
key=value2), I dont need to update the values of all the keys, since
those keys will be reading the values from this key's value.

I hope i am clear with this explanation.... ;-)

My first question is, 'IS IT POSSIBLE' ???
If yes, then how????

Thanks in advance
Inder Jeet Singh
Andrew McDonagh - 17 Apr 2006 08:32 GMT
> Hi All,
>
[quoted text clipped - 29 lines]
> Thanks in advance
> Inder Jeet Singh

Possible and most appropriate.

So you currently have

Key1 = value1
Key2 = A shared value
SomeOtherKey = A shared value
...

but its better to have
Key1 = value1
Key2 = SharedValue
SomeOtherKey = SharedValue
SharedValue = A shared value
...

Here the value of Key2 & SomeOtherKey is the name of another property
(SharedValue)

This other property is where the shared value is stored.

Pseudo code:

String valueOfKey2 = getProperty("key2);
String sharedValue  = getProperty("valueOfKey2");

system.out.println(sharedValue);
--------------

on std out we'd see:

A shared value


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.