How should I parse this simple text file in Java?
Posted
by Winston
on Stack Overflow
See other posts from Stack Overflow
or by Winston
Published on 2010-04-02T06:03:42Z
Indexed on
2010/04/02
6:13 UTC
Read the original article
Hit count: 242
I have a text file that looks like this:
grn129 agri-
ac-214 ahss
hud114 ahss
lov1150 ahss
lov1160 ahss
lov1170 ahss
lov1210 ahss
What is the best way to parse this file using Java if I want to create a HashMap with the first column as the key and the second column as the value.
Should I use the Scanner class? Try to read in the whole file as a string and split it?
What is the best way?
© Stack Overflow or respective owner