Exists mostly to make System.In palatable by transforming it into a * readLine-able BufferedReader. Out is included for completeness * and uniformity. * *
Copyright 1998 Massachusetts Institute of Technology * * @see java.lang.System * * @author Lynn Andrea Stein, las@ai.mit.edu * @version $Id: Console.java,v 1.1.1.1 2002/06/05 21:56:32 root Exp $ * */ public class Console { /** A console Reader; e.g., allows you to readLine() from the console. */ private static final BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); /** A console Writer; e.g., allows you to println() to the console */ private static final PrintWriter out = new PrintWriter ( System.out , true); /** The special console Writer for error messages. */ private static final PrintWriter err = new PrintWriter( System.err , true); /** Read a line from Console. The String returned is not terminated * with a newline. */ public static final String readln() { try { return Console.in.readLine(); } catch (java.io.IOException ioe) { // Something strange has happened. Report error and continue. Console.err.println("Console.readLine() threw IOException. Has System.in been redirected?"); return ""; } } /** Write a line to Console. The String writen is concatenated with a * newline. */ public static final void println(String s) { Console.out.println(s); } /** Write a blank line to Console. */ public static final void println() { Console.out.println(); } /** Write a line to Console. The String written is not concatenated with * a newline. */ public static final void print(String s) { Console.out.print(s); Console.out.flush(); } /** * Prevent instantiation */ private Console() {} } /* Comments: * * History: * $Log: Console.java,v $ * Revision 1.1.1.1 2002/06/05 21:56:32 root * CS101 comes to Olin finally. * * Revision 1.10 1999/07/28 22:22:04 las * Added files providing utility classes for stringTransformer pset * (mostly interfaces concerning connectors). Also modified Console to * fix a bug in print (i.e., needed to force flush()). * * Revision 1.9 1999/01/25 15:30:03 tparnell * fix javadoc to reflect file movement between packages * * Revision 1.8 1998/08/11 22:30:54 tparnell * added println() [no args] * * Revision 1.7 1998/07/28 18:55:54 tparnell * removed refrences to (now defunct) java.io.FriendlyReader * * Revision 1.6 1998/07/24 17:07:29 tparnell * Placate new javadoc behavior * * Revision 1.5 1998/07/22 20:24:46 tparnell * made in, out, and err private * * Revision 1.4 1998/07/22 15:37:13 tparnell * moved to cs101.io * * Revision 1.3 1998/07/21 19:24:54 tparnell * added private Console() * * Revision 1.2 1998/07/20 21:57:02 tparnell * Added readLine(), print(), and println() * * Revision 1.1 1998/06/08 18:11:52 tparnell * added files from Lynn * */