// Ivan Novick // Dec 28, 2007 // // command line using gcj: // $ gcj streamsio.java -C // $ cat streamsio.java | gij streamsio // // demonstrate reading from stdin and writing to stderr import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; class streamsio { public static void main(String args[]) { // create a buffered reader to read from STDIN BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String s; try { // read a line into String s and quit the loop when readLine returns null while (null != (s = reader.readLine())) { // print to STDERR System.err.println("LINE READ FROM STDIN: " + s); } } catch(IOException e) { System.out.println("IOException thrown"); } } }