2 Replies Latest reply on Feb 20, 2008 3:31 AM by 807603

    help! Exception in thread "main" java.util.NoSuchElementException

    807603
      I checked a million times and cant figure out why it isnt working!
      :(
          public class Dictionary
         {
            private TreeMap<String, Integer> dictionary = new TreeMap<String, Integer>();
             public TreeMap loadDictionary(String fname)throws Exception
            {
               Score score = new Score();
               BufferedReader in = null;
               try { in = new BufferedReader(new FileReader(fname)); }
                   catch (FileNotFoundException e) {    
                     System.out.println("File does not exist, Returning to menu");
                  }
               String line = in.readLine();
               while(line != null)
               {
                  StringTokenizer t = new StringTokenizer(line);
                  while(t.hasMoreTokens())
                  {
                     dictionary.put((String)t.nextToken(), score.getScore(t.nextToken()));
                  }
                  line = in.readLine();         
               }
               return dictionary;
            }
         
         }