Doubt in .properties file reading

Discussion in 'Java' started by singh.inderjeet@gmail.com, Apr 17, 2006.

  1. Guest

    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
     
    , Apr 17, 2006
    #1
    1. Advertising

  2. wrote:
    > 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
     
    Andrew McDonagh, Apr 17, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Do
    Replies:
    0
    Views:
    519
  2. Bob Nelson

    doubt about doubt

    Bob Nelson, Jul 28, 2006, in forum: C Programming
    Replies:
    11
    Views:
    635
  3. Replies:
    0
    Views:
    570
  4. Peter Otten
    Replies:
    2
    Views:
    125
    Cousin Stanley
    Aug 10, 2013
  5. Terry Reedy
    Replies:
    0
    Views:
    120
    Terry Reedy
    Aug 10, 2013
Loading...

Share This Page