import java.io.InputStreamReader; import java.io.BufferedReader; public class Test { public static void main(String A[]) { // build a tool for non-binary read from a default input stream BufferedReader CIN=new BufferedReader(new InputStreamReader(System.in)); // use standard input to start width ^^^^^^^^^ // create a 16-bit reader ^^^^^^^^^^^^^^^^^^^^^ // (for additional extended ascii support) // create a buffered reader ^^^^^^^^^ // (so that it can utilize a buffer for faster access // and knows how to read a whole line into a string) // prompt user for action System.out.println("Please type a few lines and end with an empty one"); // echo lines until empty line String aLine; try { do { aLine=CIN.readLine(); System.out.println(aLine); } while (!aLine.equals("")); // please note that end of file check is: aLine==null } catch (Exception e) { System.out.println("ERROR: "+e); } } }