title: splitting the results of a regular expression
body: <p>With the following code I was able to get all the necessary information out of a form, this information is;</p>
  
  <pre><code>n = 5
  p = 0.5
  lambda = 0.3
  d = 1
  n = 8
  p = 0.1
  d = 1
  p = 0.3
  </code></pre>
  
  <p>I put all this information in a HashMap, but what I actually need would be 6 hashmaps; like this</p>
  
  <pre><code>Hashmap 1
  n = 5
  p = 0.5
  Hashmap 2
  lambda = 0.3
  Hashmap 3
  d = 1
  Hashmap 4
  n = 8
  p = 0.1
  Hashmap 5
  d = 1
  Hashmap 6
  p = 0.3
  </code></pre>
  
  <p>In other words, always when I get an n as keyword, the next keyword and value should also be stored in this Hashmap, this next keyword will always be an p.</p>
  
  <p>I know it is not really possible to split a Hashmap, but I can't find any other way </p>
  
  <p>Thanks a lot</p>
  
  <pre><code>public static void main(String[] args ) throws FileNotFoundException, IOException        
  {
       File filename = new File("H:\\NetBeansProjects\\thesis2.0\\src\\thesis2\\pkg0\\txt-files\\formulier.txt");
  
       try (BufferedReader in = new BufferedReader(new FileReader(filename))) 
       {
  
          HashMap hm = new HashMap();
  
          Pattern p = Pattern.compile("\\s+(\\w+)\\s+([0-9.]+)\\s*");
          for (String line; (line = in.readLine()) != null; ) 
          {
              Matcher m = p.matcher(line);
              if (m.matches()) 
              {
                  String keyword = m.group(1);
                  String parameter = m.group(2);
  
                  hm.put(m.group(1),m.group(2));
  
                  System.out.println(m.group(1) + " = " + m.group(2));
              }
         }
      }  
  }
  </code></pre>