0

I don't understand why I keep getting the null exception. I've checked for null with while hasNextLine() loop. Here is my code. Please help me out! Thanks!

    public class SpellCheckerTool {

  private HashSet<String> hashedDictionary;
  private ArrayList<String> listDictionary;

  /**
   * Instantiate this SpellCheckerTool.
   * @param dictionaryFileName the dictionary to use for testing
   * spellings
  */
  public SpellCheckerTool(String dictionaryFileName) {
    // inialize both dictionaries
    try{
      Scanner sc = new Scanner(new File(dictionaryFileName));
      while (sc.hasNextLine()){
        String input = sc.nextLine();

        hashedDictionary.add(input);
        listDictionary.add(input);



      }
    }

    catch (FileNotFoundException e){
      System.out.println("File Not Found");
    }
blurfus
  • 13,485
  • 8
  • 55
  • 61
Bob
  • 1

0 Answers0