9

I'm trying to set up environment-specific properties in a file, customized for each device running the code. I'd like to be able to nest some properties in others, for example:

browser=chrome
baseUrl=${server}/app/login.do
server=http://localhost

I'd like to be able to get http://localhost/app/login.do when I get the baseUrl property.

Does java.util.Properties support this behavior? If not, is there another core class that does?

Mar
  • 7,765
  • 9
  • 48
  • 82
  • You can use Apache Configuration to do this, but no in built class, unless you write it yourself. – Peter Lawrey Jan 27 '15 at 23:40
  • No. Easy enough to test, and probably quicker and certainly more reliable than asking here. – user207421 Jan 28 '15 at 01:07
  • 1
    @EJP Testing `Properties`'s *default* behavior is easy, but there may be options to alter the behavior a bit, thus asking. I also asked if there is another core class that *does* provide this behavior. – Mar Jan 28 '15 at 17:12

1 Answers1

4

The answer is No. java.util.Properties operates on Strings only.

Each key and its corresponding value in the property list is a string. (From Javadoc)

Edit: No core Java class does that, as no core Java framework/class is designed to do such a thing. I like Typesafe's Config library.

Aleksandr Panzin
  • 1,987
  • 1
  • 14
  • 11
  • That answers the first part of my question, but doesn't look at other core classes that could fill the need. – Mar Jan 28 '15 at 17:10