
Untitled
By: a guest on
May 7th, 2012 | syntax:
None | size: 0.63 KB | hits: 10 | expires: Never
Read from a Text File into a hash map or list [closed]
public class ReadToHashmap {
public static void main(String[] args) throws Exception {
Map<String, String> map = new HashMap<String, String>();
BufferedReader in = new BufferedReader(new FileReader("example.tab"));
String line = "";
while ((line = in.readLine()) != null) {
String parts[] = line.split("t");
map.put(parts[0], parts[1]);
}
in.close();
System.out.println(map.toString());
}
}
title en_CA
1 In accordance blah bla blah
{1=In accordance blah bla blah, title=en_CA}