You will get java.lang.NullPointerException
at the line if(line.equalsIgnoreCase(s1))
, because in your while loop, you have a check if line != null
, and until the line is not null, your loop executing and when the line=null
, code exit from loop and your if Condition occurs in which you checked if(line.equalsIgnoreCase(s1))
and since line=null
, so you will get NullPointerException
at your if condition.
I think you want this :
while((line = reader.readLine())!= null){
if(line.equalsIgnoreCase(s1))
out.println("Shkati");
else
{
out.println("sharma");
}
}