title: Command Line Pipe Input in Java
body: <p>Here is a simple piece of code:</p>
  
  <pre><code>import java.io.*;
  public class Read {
   public static void main(String[] args) {
       BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
    while(true)
    {
     String x = null;
     try{
      x = f.readLine();
     }
     catch (IOException e) {e.printStackTrace();}
     System.out.println(x);
    }
   }
  }
  </code></pre>
  
  <p>I execute this as :    java Read &lt; input.txt</p>
  
  <p>Once the input.txt is completely piped into the program, x keeps getting infinite nulls. Why is that so? Is there a way by which I can make the Standard In(Command Line) active after the file being fed into the code is done?
  I've tried closing the stream and reopening, it doesn't work. Reset etc also.</p>