title: How to read a text file and store with hashmap?
body: <p>I have a text file with integers in 3 columns and with multiple entries for each number on the first column, like the sample above:</p>
  
  <pre><code>1 23 1
  1 24 2
  1 57 1
  1 10 1
  1 59 2
  1 31 2
  1 38 1
  1 11 1
  2 39 2
  2 40 1
  2 15 1
  2 74 2
  </code></pre>
  
  <p>I can read the contents of the file with the code shown above</p>
  
  <pre><code>public static void main(String[] args) {
  
      try (BufferedReader br = new BufferedReader(new FileReader("/home/user/Desktop/file.txt")))
          {
              String sCurrentLine;
              while ((sCurrentLine = br.readLine()) != null) {
                  System.out.println(sCurrentLine);
              }
          } 
      catch (IOException e) {
                  e.printStackTrace();
          } }
  </code></pre>
  
  <p>but I want to use hashmap to join all the entries for every different number of the first column in one line like this:</p>
  
  <pre><code>1 23 1 24 2 57 1 10 1 59 2 31 2 38 1
  2 39 2 40 1 15 1 74 2
  </code></pre>
  
  <p>Do you have any suggestion?
  Thanks!</p>