Doubt in .properties file reading

S

singh.inderjeet

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
 
A

Andrew McDonagh

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,052
Latest member
KetoBeez

Latest Threads

Top