# HashMap or other collection?

I need to parse a space- delimited text file. I want to read the file and do operations for each cell. Here is how I am parsing the file:

String line;
Map<String,String> mapFile = new HashMap<String, String>(19);
mapFile.put("valueCol1", line.substring(0,19));
mapFile.put("valueCol2", line.substring(19,45));
mapFile.put("valueCol3", line.substring(45,50));
mapFile.put("valueCol4", line.substring(50,54));
}


Is this right, or should I use other types of collections?

• Wait. Aren't you (always) overwrite the previous line with the current one? – coderodde Apr 22 '16 at 9:00
• Also, could you post the entire method containing your current code snippet? This will bring the context into awareness, and, thus, allow better answers. – coderodde Apr 22 '16 at 9:10
• Welcome to Code Review! Does your code work as you would like it to? – SirPython Apr 22 '16 at 14:07