title: Java read txt file to hashmap, split by ":"
body: <p>I have a txt file with the form:</p>
  
  <pre><code>Key:value
  Key:value
  Key:value
  ...
  </code></pre>
  
  <p>I want to put all the keys with their value in a hashMap that I've created. How do I get a <code>FileReader(file)</code> or <code>Scanner(file)</code> to know when to split up the keys and values at the colon (:) ? :-)</p>
  
  <p>I've tried:</p>
  
  <pre><code>Scanner scanner = new scanner(file).useDelimiter(":");
  HashMap&lt;String, String&gt; map = new Hashmap&lt;&gt;();
  
  while(scanner.hasNext()){
      map.put(scanner.next(), scanner.next());
  }
  </code></pre>