0

Is there any way to assign same value for multiple properties in File.Properties

Example:

Currently, I have properties files entries like this:

global.display.name = Display Name
user.display.label=Display Name
admin.display.dispname=Display Name
service.displayname=Display Name
report.displayname = Display Name

What I want to achieve is something like this, in order to eliminate duplicate entries

global.display.name = user.display.label= admin.display.dispname = Display Name

or

 global.display.name, user.display.label, admin.display.dispname = Display Name

Is there any other alternate solution available for this?

Note: I cannot use a single property entry like display.name=Display name. I need multiple entries (names) with the same value.

Thickar
  • 171
  • 1
  • 8
  • Do you use some library or Framework? As I know .properties uses only (key=value) by default – Dred Apr 09 '19 at 06:17
  • You need something more sophisticated than just properties. Look at [this answer](https://stackoverflow.com/a/8869578/5761558) that uses commons-configuration to support reusing properties in the file – ernest_k Apr 09 '19 at 06:19
  • http://commons.apache.org/proper/commons-configuration/apidocs/org/apache/commons/configuration2/PropertiesConfiguration.html # properties can reference other properties base.prop = /base first.prop = ${base.prop}/first second.prop = ${first.prop}/second I saw this in official documentation but this doesn't work for me. I dont use any library or framwork @Dred – Thickar Apr 09 '19 at 06:42
  • Ok. Do you use XML or set your .properties inside class? Is [this](https://gist.github.com/workspc/a999801492f0ae2cbe07f36e6e256ce8) you are looking for? – Dred Apr 09 '19 at 06:45

0 Answers0