Can we have a value inside the properties file as an array of values?

I have a properties file. I know that it can be given

key = value1, value2,value3 

inside the properties file.

My requirements:

 key = value1[1, 2], value2[3,4] 

Is it possible?

+4
source share
2 answers

I think you can, but after that you should write a parser, divided into "[]" and ","

value is just a string:

 String value = p.getProperty(key) 

and here is your value value = "value1[1, 2], value2[3,4]"

but do not do this, think more reasonably.

+1
source

It may be easier to change the structure of the property file to have something like this:

 key.array0 = 1,2 key.array1 = 3,4 

Now filter out the "key.array*" , create arrays from all the values ​​and add a list of arrays to your map.

+1
source

Source: https://habr.com/ru/post/1335954/


All Articles