I have a '|' delimited csv file with 2 columns:
A |B
87657|5
87688|8
32134|4
...
I want to make a Map by reading this file, taking the column A values as string, and column B values as int.
I do (with delimiter = "|"):
Map<String, Integer> output = new HashMap<>();
assert delimiter.length() == 1;
int count = 0;
for(String line: Files.readAllLines(Paths.get(docidFreq), Charset.defaultCharset())) {
count++;
//skipping header row
if (count == 1 ) {
continue;
}
String tokens[] = line.split(delimiter);
output.put(tokens[0], Integer.parseInt(tokens[1]));
}
return output;
However, the map contains single digit keys and values like (No relation to the sample file lines given above):
1:2
8:5
9:3
...
What am I doing wrong?
delimiteris..