title: How can I run my java program for a whole folder?
body: <p>I have written a java code for counting the instruction frequency using hashmap. Now I want to run this file for a whole folder at once which has several .txt files.</p>
  
  <pre><code>class HashMapCount
  {
      public static void main (String[] args) throws java.lang.Exception
      {
         HashMap h=new HashMap();                        
         FileInputStream fin=new FileInputStream("C:\\test.txt");
         BufferedReader br=new BufferedReader(new InputStreamReader(fin));
         String n;
           while((n=br.readLine())!=null)
                 {
                     if(h.containsKey(n))
                           {
                             int i=(Integer)h.get(n);
                             h.put(n,(i+1));
                           }
                     else
                             h.put(n, 1);
                  }
  
      Set setOfKeys = h.keySet();
  
       Iterator iterator = setOfKeys.iterator();
  
      while (iterator.hasNext()) 
           {
               String key = (String) iterator.next();
  
               Integer value = (Integer)h.get(key);
  
               System.out.println("Key: "+ key+", Value: "+ value);    
            }
    }
  }
  </code></pre>