|
Hi, when I run my code I get a NullPointerException:null. Here is the part of the code where the error occurs:
import java.util.*;
import java.io.*;
public class Decrypt
{
ArrayList<String> dictionary;
ArrayList<String> encryptedText;
public void dictionaryReader() throws IOException
{
try
{
FileReader reader = new FileReader("C:/Dictionary.txt");
Scanner file=new Scanner(reader);
while(file.hasNext())
{
dictionary.add(file.nextLine());
}//while
}//try
catch(IOException exception)
{
System.out.println("**Error**");
System.out.println("The dictionary file has the wrong name or is in the wrong directory.");
System.out.println("Exiting Program");
System.exit(0);
}//catch
}//dictionaryReader
}//Decrypt
The error is at dictionary.add(file.nextLine()); It says:
java.lang.NullPointerException
at Decrypt.dictionaryReader(Decrypt.java:93)
at Decrypt.main(Decrypt.java:24)
NullPointerException:
null
Thanks,
Chris
|