Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.63 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Read from a Text File into a hash map or list [closed]
  2. public class ReadToHashmap {
  3.     public static void main(String[] args) throws Exception {
  4.         Map<String, String> map = new HashMap<String, String>();
  5.         BufferedReader in = new BufferedReader(new FileReader("example.tab"));
  6.         String line = "";
  7.         while ((line = in.readLine()) != null) {
  8.             String parts[] = line.split("t");
  9.             map.put(parts[0], parts[1]);
  10.         }
  11.         in.close();
  12.         System.out.println(map.toString());
  13.     }
  14. }
  15.        
  16. title   en_CA
  17. 1       In accordance blah bla blah
  18.        
  19. {1=In accordance blah bla blah, title=en_CA}