Source of ConIO.java


  1: //ConIO.java

  3: package scobey.xtras;
  4: import java.io.*;


  7: /**
  8:  * A utility class for console I/O.
  9:  * It provides a keyboard object, a screen object, and
 10:  * two pause functions.
 11:  */
 12: public class ConIO
 13: {
 14:     /**
 15:      * A public keyboard object
 16:      */
 17:     public static BufferedReader keyboard =
 18:         new BufferedReader(new InputStreamReader(System.in));

 20:     /**
 21:      * A public screen object
 22:      */
 23:     public static PrintWriter screen =
 24:         new PrintWriter(System.out, true);

 26:     /**
 27:      * A public pause method
 28:      * @param s A string to be displayed prior to the pause
 29:      */
 30:     public static void pause(String s)
 31:     throws IOException
 32:     {
 33:         if (!s.equals("")) screen.println(s);
 34:         screen.print("Press Enter to continue ... ");
 35:         screen.flush();
 36:         keyboard.readLine();
 37:     }
 38: }