Reputation: 1492
I want to configure a property in my properties file. But that will not be a static value. For example,
var=abc some_unknown_string_here def
I will set the value for the unknown string within the java program. Is it possible to have a configuration like this?
Upvotes: 1
Views: 1057
Reputation: 10299
You can store format string as a property, e.g.:
Properties properties = new Properties();
properties.put("foo", "hi, %s");
String s = properties.getProperty("foo");
System.out.println(String.format(s, "bar"));
Upvotes: 3
Reputation: 59660
As a hack you can do like this:
In properties file:
var = abc%_%xyz
In java file
//--- code to load property file
String propVar = properties.getProperty("var");
String myVar = propVar.replace("%_%","the_string_want_to_set_here");
Upvotes: 3