whenever i run the following code it gives me NullPointerException.although i checking if not null then add, but still giving that eception.the file is a plain text(.txt)
what could be wrong?
BufferedReader br2 = new BufferedReader(new FileReader(file));
ArrayList<String> keArrayList=null;
for(int i=0;br2.readLine()!=null;i++)
{
String letter= br2.readLine();
if (letter!=null)
keArrayList.add(i,letter);
}
keArrayListisnull:Change to: