With the following properties file:
foo=hello, world!
bar=first,second
I would like to retrieve the first item as a string and the second as an array. I would have thought that getString
vs getStringArray
would deal with this, but it doesn't - getString("foo")
just gets everything before the comma, i.e. "hello".
If I disable delimiter parsing using setDelimiterParsingDisabled
, foo is fine, but this also changes the behaviour of getStringArray("bar")
to return a single-element array!
I can't find how I can explicitly tell it how I want it to interpret an individual config item, either as a string or as an array. I don't want to put the config items into separate config files with different delimiter rules, and I'd prefer to use a comma as the delimiter for the getStringArray case.
To elaborate, this snippet prints either hello - 2
or hello, world! - 1
- I want it to print hello, world! - 2
!
AbstractFileConfiguration config = new PropertiesConfiguration();
config.setFileName("C:\\temp\\temp.properties");
//config.setDelimiterParsingDisabled(true);
config.load();
System.out.println(config.getString("foo") + " - " + config.getStringArray("bar").length);