temp = line.split(",");
if (i < paymentFieldsMapIndex.size()) {
paymentFields.put(paymentFieldsMap.get(next).toString(), temp[i]);
}
This code splits up a comma delimited string into substrings and populates a HashMap value using the resulting substrings.
Some substring values look funny in the resulting HashMap, looks like it's due to the presence of commas in the token.
For instance
,"LONDON,UNITED KINGDOM",
in the string appears in the HashMap like
Key = key, Value = "LONDON
I thought that String split(), will not break up substrings containing the delimiter if they are enclosed in double quotes?
I've also tried escaping the embedded comma like
,"LONDON\,UNITED KINGDOM",
but the string in the HashMap looks like
Key = key, Value = "LONDON\
Am I missing something, or is there any way around this problem? Thanks.