title: How to read until end of file (EOF) using BufferedReader in Java?
body: <p>I have problem with reading the input until <code>EOF</code> in <code>Java</code>. In here, there are single input and the output consider the input each line.</p>
  
  <p><strong>Example:</strong></p>
  
  <p><strong>input:</strong></p>
  
  <pre><code>1
  2
  3
  4
  5
  </code></pre>
  
  <p><strong>output:</strong></p>
  
  <pre><code>0 
  1
  0
  1
  0
  </code></pre>
  
  <p>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 <code>EOF</code>) using <code>BufferedReader</code> in Java.</p>
  
  <p>This is my code:</p>
  
  <pre><code>BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
  StringBuffer pr = new StringBuffer("");
  
  String str = "";
  while((str=input.readLine())!=null &amp;&amp; str.length()!=0) {
      BigInteger n = new BigInteger(input.readLine());
  }
  </code></pre>