title: Reading a text file to a HashMap in Java
body: <p>I have a text file in the following format:</p>
  
  <pre><code>Student1 Marks
  Student2 Marks
  </code></pre>
  
  <p>The first column is the key.</p>
  
  <p>This is what I have tried so far</p>
  
  <pre><code>Scanner scanner = new Scanner(new FileReader("marks.txt"));
  
      HashMap&lt;String,Integer&gt; map = new HashMap&lt;String,Integer&gt;();
  
      while (scanner.hasNextLine()) {
          String[] columns = scanner.nextLine().split("\t");
  
          map.put(columns[0],columns[1]);
      }
  
      System.out.println(map);        
  
  
  }
  </code></pre>