Quote Originally Posted by AlexVV View Post
You assign:
Code:
allTxt = br.readLine();
followed by
Code:
cap = allTxt.length();
without checking if allTxt is null.
If br.readLine() returns null, allTxt is null.
If allTxt is null, you get a null pointer exception thrown.
It is thrown because you are trying to use a reference (allTxt) which is pointing to nothing (null), not the assignment of cap.
Wouldn't I want to check if br.readLine() is null?