Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does java.util.Properties support nested properties?

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?

like image 378
Martin Avatar asked Jan 27 '15 23:01

Martin


1 Answers

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.

like image 119
Aleksandr Panzin Avatar answered Sep 23 '22 03:09

Aleksandr Panzin