Can Java properties file reference other properties file?
## define a default directory for Input files dir.default=/home/data/in/ dir.proj1=${dir.default}p1 dir.proj2=${dir.default}p2 dir.proj3=${dir.default}p3
Is this possible?
Property keys and values are simply Strings. No processing happens to them, so you can't refer to another value in a value.
First, we create a Properties object to hold all our merged properties. Next, we loop over the Properties objects we are going to merge. We then call the stringPropertyNames() method to get a set of property names. Then we loop through all the property names and get the property value for each name.
Chris Mair's XProperties class may be a good starting point.
You can substitute a constant anywhere in the property value, and even have more than one constant within a value, as in the following example:
CONST_1 = shoes and ships CONST_2 = sealing wax SomeValue = {CONST_1} and {CONST_2}
In this example, the "SomeValue" property evaluates to "shoes and ships and sealing wax."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With