title: Store the data from text file to a hashmap
body: <p>I am trying to read a text file and store with a hashmap. The file contains information like this:</p>
  <pre><code>1946-01-12;13:00:00;0.3;G 
  1946-01-12;18:00:00;-2.8;G
  1946-01-13;07:00:00;-6.2;G 
  1946-01-13;13:00:00;-4.7;G
  1946-01-13;18:00:00;-4.3;G 
  1946-01-14;07:00:00;-1.5;G
  1946-01-14;13:00:00;-0.2;G
  </code></pre>
  <p>I want to store the dates as keys and then &quot;13:00:00;0.3;G&quot; as value, where 13:00 is time, 0.3 is temperature and G represent a quality code. I wonder if this is even possbile since many rows in the file has the same date? I already wrote a code for storing the data in a list, but now I want to store it in a map instead. My old code looks like this:</p>
  <pre><code>/**
   * Provides methods to retrieve temperature data from a weather station file.    
   */
  public class WeatherDataHandler {
  
          private List&lt;Weather&gt; weatherData = new ArrayList&lt;&gt;();
  
          public void loadData(String filePath) throws IOException {
              List&lt;String&gt; fileData = Files.readAllLines(Paths.get(&quot;filepath&quot;));
              for(String str : fileData) {
                  List&lt;String&gt; parsed = parseData(str);
                  LocalDate date = LocalDate.parse(parsed.get(0));
                  LocalTime time = LocalTime.parse(parsed.get(1));
                  double temperature = Double.parseDouble(parsed.get(2));
                  String quality = parsed.get(3);
                  
                  //new Weather object
                  Weather weather = new Weather(date, time, temperature, quality);
                  weatherData.add(weather);       
              }
          }
  
          private List&lt;String&gt; parseData(String s) {
              return Arrays.asList(s.split(&quot;;&quot;));
          }
  </code></pre>
  <p>I got stuck when implementing the hashmap. I started with some code below, but I do not know how to loop over a sequence of dates. What is the simplest way to store the data from the file in a map?</p>
  <pre><code>public class WeatherDataHandler {
              public void loadData(String filePath) throws IOException {
                  Map&lt;LocalDate, String&gt; map =new HashMap&lt;LocalDate, String&gt;();
                  BufferedReader br = new BufferedReader(new FileReader(&quot;filepath&quot;));
              String line=&quot;&quot;;
              int i=0;
              while (line != null) {
                  line = br.readLine();
                  map.put(i,line);
                  i++;
              }
                  String date=&quot;&quot;;
                  String time=&quot;&quot;;
                  String temperature=&quot;&quot;;
                  String quality=&quot;&quot;;
                  for(int j=0;j&lt;map.size();j++){
                      if(!(map.get(j)== null)){
                          String[] getData=map.get(j).toString().split(&quot;\\,&quot;);
                          date = getData[0];
                          time = getData[1];
                          temperature = getData[2];
                          quality = getData[3];
                      }
                  }
              }
  </code></pre>