title: How can I read text file with hashmap that contain three columns?
body: <p>I want to write A Star Algorithm by java program and I want to read the distance from the Text file like this      </p>
  
  <pre><code>    89  R A
      118 A T
      140 M S
      85  B U
  </code></pre>
  
  <p>As you see in my text file I have three columns but with this code that I wrote it will give me just two columns but I want to read all of my columns which is three columns as you see in above</p>
  
  <pre><code>List&lt;String&gt; halist = new ArrayList&lt;String&gt;();
  
  File f = new File("mapfile.txt");
  
  FileInputStream fis = new FileInputStream(f);
  
  BufferedInputStream bis = new BufferedInputStream(fis);
  
  dis = new DataInputStream(bis);
  
  while ( (record=dis.readLine()) != null ) {
      Map&lt;Integer, String&gt; hamap = new HashMap&lt;Integer, String&gt;();
      String[] columns = record.split(" ");
      hamap.put(Integer.valueOf(columns[0]), columns[1]);
  
      for(Map.Entry&lt;Integer,String&gt; m :hamap.entrySet()) {
          System.out.println(m.getKey()+" "+m.getValue());
      }
  }
  </code></pre>