title: Populate a HashMap with all the entries stored in a .properties file
body: <p>How do I populate my <code>HashMap</code> with all the entries stored in a separate <code>.properties</code> file ?
  I have a file <code>resume.properties</code> placed along with the <code>class</code> files in the bin folder in Eclipse. </p>
  
  <p>The file consists of entries like this</p>
  
  <pre><code>available = 1
  bismarck = 1
  employees = 1
  reports = 1
  home = 1
  company = 1
  work = 2
  ........
  </code></pre>
  
  <p>I want this entries to be populated into my HashMap as soon as the constructor of that class is invoked.</p>
  
  <pre><code>public class TextClassifier {
  
    static HashMap&lt;String,Integer&gt; resume = new HashMap&lt;String, Integer&gt;();
  
    public TextClassifier(){
      try {
        properties.load(TextClassifier.class.getResourceAsStream("resume.properties"));              
      }
      catch (Exception e) {}
  
      for (String key : properties.stringPropertyNames()) {
        String value = properties.getProperty(key);
        resume.put(key, Integer.valueOf(value));
      }
  
    }
  
    public static void printHashmap(HashMap&lt;String,Integer&gt; map){
      for(Map.Entry&lt;String, Integer&gt; entry:map.entrySet()){
        int val=entry.getValue();
        String key=entry.getKey();
        System.out.println(key + " = " + val);
      }
    }
  
    public static void main(String args[]){
      new TextClassifier();
      TextClassifier.printHashmap(TextClassifier.resume);
  
    }
  }
  </code></pre>
  
  <p>But when I print the entries using the printAll method and match them with those in the actaul file, I do not find them matching. THere are entries which are printed which are not there in the file !!</p>
  
  <p>I am populatin many HashMaps (which I have not shown) and so maybe entries from other files are getting printed. Where is the error ?</p>