I would like to know if there is any way to use a key as another key's value in .properties files.
For example is this possible, or is there any other way to achieve something similar to this?
key = another_key
app.name=Stack Over Flow
app.title.welcome=Welcome to {app.name}
so when i get the value of app.title.welcome
it should be "Welcome to Stack Over Flow
"
The Apache Commons Configuration Project has an implementation capable of doing variable interpolation.
Read the section named Variable Interpolation
application.name = Killer App
application.version = 1.6.2
application.title = ${application.name} ${application.version}
You would need this third-party library in your class path, but on the other hand you will not have to worry about writing yet another implementation for this :)
You might like to read the Properties How To as well.
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