Here's how I would do it! I'm almost exclusively a Java programmer since 2000, so it might be a little old fashioned. There is one line in particular I'm a little proud of:
new InputStreamReader(fin, "UTF-8");
http://www.joelonsoftware.com/articles/Unicode.html
Enjoy!
import java.io.*;
import java.util.*;
public class StackOverflow2565230 {
public static void main(String[] args) throws Exception {
Map<String, String> m = new LinkedHashMap<String, String>();
FileInputStream fin = null;
InputStreamReader isr = null;
BufferedReader br = null;
try {
fin = new FileInputStream(args[0]);
isr = new InputStreamReader(fin, "UTF-8");
br = new BufferedReader(isr);
String line = br.readLine();
while (line != null) {
// Regex to scan for 1 or more whitespace characters
String[] toks = line.split("\\s+");
m.put(toks[0], toks[1]);
line = br.readLine();
}
} finally {
if (br != null) { br.close(); }
if (isr != null) { isr.close(); }
if (fin != null) { fin.close(); }
}
System.out.println(m);
}
}
And here's the output:
julius@flower:~$ javac StackOverflow2565230.java
julius@flower:~$ java -cp . StackOverflow2565230 file.txt
{grn129=agri-, ac-214=ahss, hud114=ahss, lov1150=ahss, lov1160=ahss, lov1170=ahss, lov1210=ahss}
Yes, my computer's name is Flower. Named after the skunk from Bambi.
One final note: because close() can throw an IOException, this is how I would really close the streams:
} finally {
try {
if (br != null) br.close();
} finally {
try {
if (isr != null) isr.close();
} finally {
if (fin != null) fin.close();
}
}
}