/* Example of System.in usage */ import java.io.IOException; import java.io.DataInputStream; //import com.mw.io.SystemInput; // UNCOMMENT THIS FOR EMBEDDED SYSTEM.IN public class TrivialApplication { public static void main(String args[]) { System.out.println( "\nAnything you type in the System.in window that is followed by Enter, Return, or Command-D will be \nechoed to the System.out output window. \nType \"bye\" to exit the program.\n" ); byte input[] = new byte[255]; input[0] = 0x0A; boolean done = false; //SystemInput sysIn = new SystemInput(); // UNCOMMENT THIS FOR EMBEDDED SYSTEM.IN try { String str = null; DataInputStream ds = new DataInputStream( System.in); // Keep going until while we get a return or enter (i.e. newline char) while(!done) { str = ds.readLine(); if ( str == null) { System.out.println( "[EOF]"); return; } else { System.out.println("Echo: "+ str); done = str.equals("bye"); } } //sysIn.dispose(); // UNCOMMENT THIS FOR EMBEDDED SYSTEM.IN } catch ( IOException e) { System.out.println( "An IOException occured in TrivialApplication.main()."); } catch ( Exception e) { System.out.println("An exception "+ e.toString()+" occured in TrivialApplication.main()."); //sysIn.dispose(); // UNCOMMENT THIS FOR EMBEDDED SYSTEM.IN } } }