In my properties file I have one property, which contains a comma separated list of values
In my code, I would like to load that property in, split it from the commas, and add each value into an array. I also want to make sure I don't have values in the array due to whitespace etc
example property :
prop_allowed_extensions = .jpeg,tiff, .txt
I have come up with this so far, but it feels dirty, is there a more elegant solution?
String test = classProperties.getProperty("prop_allowed_extensions", "txt, jpeg");
String[] splitString = StringUtils.split(test, ',');
String[] newString = new String[splitString.length];
for (int i = 0; i < splitString.length; i++)
{
newString[i] = StringUtils.trim(splitString[i]);
}
I just want the text of the file extension, would it be appropriate to use a regular expression to remove whitespace/non-letters?