In the sample code below, why does a null pointer exception get thrown when I try to get the value of string two? The code works fine without br.close(). Is there some concept of BufferedReader that I am missing?
public String readString() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s="";
s=br.readLine();
br.close();
return s;
}
public static void main(String[] args) throws IOException {
Test obj = new Test();
String one = obj.readString();
String two = obj.readString();
}