I have problem with reading the input until EOF
in Java
. In here, there are single input and the output consider the input each line.
Example:
input:
1
2
3
4
5
output:
0
1
0
1
0
But, I have coded using Java, the single output will printed when I was entering two numbers. I want single input and print single output each line (terminate EOF
) using BufferedReader
in Java.
This is my code:
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
StringBuffer pr = new StringBuffer("");
String str = "";
while((str=input.readLine())!=null && str.length()!=0) {
BigInteger n = new BigInteger(input.readLine());
}