I am using a properties file in my java project for storing the path of various resources. Ex :- Here is my properties file :-
MACHINE_NAME = "//pranay"
Json_path1 = MACHINE_NAME//Json//j1.txt
Json_path2 = MACHINE_NAME//Json//j2.txt
The value of key MACHINE_NAME is not getting replaced with its value i.e pranay in another keys such as Json_path1 and Json_path2. Therefore i am unable to get the correct path. How to give the key MACHINE_NAME so that its value gets replaced in the other key values.
You can't do this automatically - it's simply not a feature of Java property files. You'll need to write code to do this wherever you plan to load/use the properties file.
You should think about:
${MACHINE_NAME}
instead of just MACHINE_NAME
${...}
of course)MACHINE_NAME = ${USER_NAME}-laptop
- and how to handle cycles if soSee more on this question at Stackoverflow