title: What could be wrong here?
body: <p>Can anyone give me what could be wrong here?</p>
  
  <pre><code>    import java.io.BufferedInputStream;
      import java.util.HashMap;
      import java.util.Map;
      import java.util.Arrays;
      import java.io.IOException;
  
      public class TopWordsFinder {
  
        /**
         * Map of &lt;word length, &lt;word content, count in text&gt;&gt; Use some different, or
         * even multiple data structures if it makes more sense to you.
         */
        Map&lt;Integer, Map&lt;String, Integer&gt;&gt; wordsByLength = new HashMap&lt;&gt;();
  
        public static void main(String[] args) {
          new TopWordsFinder().findTopWords();
        }
  
        private void findTopWords() {
          readWords(); // Read words to data structure
          printTopWords(); // Print words from data structure
        }
  
        // Reads words from file and stores in some data structure
        // Make sure to check the definition of word in context of this puzzle in
        // class javadoc
     private void readWords() {
          BufferedInputStream in = new BufferedInputStream(TopWordsFinder.class.getResourceAsStream("c:/book-text.txt"));
          StringBuilder word = new StringBuilder("");
          try{
              while (in.available() &gt; 0) {
                  char c = (char) in.read();
                  if(Character.isAlphabetic(c)){
                      if(Character.isUpperCase(c)){
                          c = Character.toLowerCase(c);
                      }
                      word.append(c);
                  }else{
                      saveWord(word.toString());
                      word.delete(0, word.length()-1);// Reset the sequence
                  }
              }
          } catch (IOException e) {
              System.out.println("Error: "+e);
          }
      }
  private void printTopWords() {
          Integer[] lengths = wordsByLength.keySet().toArray(new Integer[wordsByLength.keySet().size()]);
          Arrays.sort(lengths);
          for(int i = lengths.length-1; i&gt;=0; i--){
              for(String word : wordsByLength.get(lengths[i]).keySet()){
                  if(wordsByLength.get(lengths[i]).get(word) &gt;= 3){
                      System.out.println("Sõna: "+word+" sõna pikkus: "+word.length()+" kordusi: "+wordsByLength.get(lengths[i]).get(word));
                      return;
                  }
              }
          }
      }
  
   private void saveWord(String word) {
      // FILL IN HERE: Store word in data structure you chose
          if(wordsByLength.get(word.length()) == null){
              wordsByLength.put(word.length(), new HashMap&lt;String, Integer&gt;());
          }
          if(wordsByLength.get(word.length()) == null){
              wordsByLength.get(word.length()).put(word, 1);
          }else{
              int n = wordsByLength.get(word.length()).get(word);
              wordsByLength.get(word.length()).put(word, ++n);
          }
      }
  }
  </code></pre>
  
  <p>This is my java work, but I'm getting <code>Error: java.io.IOException: Stream closed</code>.</p>