|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sdsu.io.Console
This class is an extention of the console class found in Gary Cornell and Cay S. Horstmann, Core Java. The orginal class had 6 methods, this one has 40+. This class provides simple methods for reading from the stantard input and writing to the standard output. Input is done via statements like Console.readInt() and Console.readInt( "Prompt string" ). No exceptions are thrown on input. If there is a read error, the program will exit with a message. If you need to handle exceptions use sdsu.io.ASCIIInputStream. Output is done via Console.print( x ), Console.println( x ) or Console.print( "x = % .5f\n", x). The later takes a format string like printf in C. The format code has the following structure
Constructor Summary | |
Console()
|
Method Summary | |
static boolean |
bad()
Deprecated. |
static boolean |
checkError()
Flushes the print stream and returns whether or not there was an error on the output stream. |
static boolean |
eof()
Determines if stream is has reach end of file. |
static void |
flush()
Forces the contents of the ouput buffer to be displayed on standard out. |
static void |
flushLine()
Causes the next I/O operation to start at the beginning of the next input line. |
static void |
main(java.lang.String[] args)
Example uses of this class |
static void |
print(boolean value)
Prints a boolean and insures that the contents of output buffer is printed on standard out. |
static void |
print(char value)
Prints a char and insures that the contents of output buffer is printed on standard out. |
static void |
print(char[] value)
Prints an array of characters and insures that the contents of output buffer is printed on standard out. |
static void |
print(double value)
Prints a double and insures that the contents of output buffer is printed on standard out. |
static void |
print(float value)
Prints a float and insures that the contents of output buffer is printed on standard out. |
static void |
print(int value)
Prints a integer and insures that the contents of output buffer is printed on standard out. |
static void |
print(long value)
Prints a long integer and insures that the contents of output buffer is printed on standard out. |
static void |
print(java.lang.Object value)
Prints an object and insures that the contents of output buffer is printed on standard out. |
static void |
print(java.lang.String value)
Prints a string and insures that the contents of output buffer is printed on standard out. |
static void |
print(java.lang.String format,
char value)
prints a character following printf conventions |
static void |
print(java.lang.String format,
double value)
prints a formatted double (and float) following printf conventions |
static void |
print(java.lang.String format,
long value)
prints a formatted long integer (and integer) following printf conventions |
static void |
print(java.lang.String format,
java.lang.String value)
prints a formatted string following printf conventions |
static void |
println()
Prints a newline then insures that the contents of output buffer is printed on standard out. |
static void |
println(boolean value)
Prints a boolean followed by a newline then insures that the contents of output buffer is printed on standard out. |
static void |
println(char value)
Prints a character followed by a newline then insures that the contents of output buffer is printed on standard out. |
static void |
println(double value)
Prints a double followed by a newline then insures that the contents of output buffer is printed on standard out. |
static void |
println(float value)
Prints a float followed by a newline then insures that the contents of output buffer is printed on standard out. |
static void |
println(int value)
Prints a integer followed by a newline then insures that the contents of output buffer is printed on standard out. |
static void |
println(long value)
Prints a long integer followed by a newline then insures that the contents of output buffer is printed on standard out. |
static void |
println(java.lang.Object value)
Prints a object followed by a newline then insures that the contents of output buffer is printed on standard out. |
static void |
println(java.lang.String value)
Prints a string followed by a newline then insures that the contents of output buffer is printed on standard out. |
static boolean |
readBoolean()
Reads an ASCII boolean value. |
static boolean |
readBoolean(java.lang.String prompt)
Reads an ASCII boolean value, after displaying given prompt. |
static char |
readChar()
Read an ASCII character and convert it into the internal char format. |
static char |
readChar(java.lang.String prompt)
Read an ASCII character and convert it into the internal char format, after displaying the given prompt. |
static double |
readDouble()
Reads an ASCII decimal floating point number. |
static double |
readDouble(java.lang.String prompt)
Reads an ASCII decimal floating point number, after displaying given prompt. |
static float |
readFloat()
Reads an ASCII decimal floating point number. |
static float |
readFloat(java.lang.String prompt)
Reads an ASCII decimal floating point number, after displaying given prompt. |
static int |
readInt()
Reads an ASCII decimal integer. |
static int |
readInt(java.lang.String prompt)
Reads an ASCII decimal integer, after displaying given prompt. |
static java.lang.String |
readLine()
Reads in a line that has been terminated by a \n, \r, \r\n or EOF. |
static java.lang.String |
readLine(java.lang.String prompt)
Reads in a line that has been terminated by a \n, \r, \r\n or EOF, after displaying the given prompt. |
static long |
readLong()
Reads an ASCII decimal long. |
static long |
readLong(java.lang.String prompt)
Reads an ASCII decimal long, after displaying the given prompt. |
static short |
readShort()
Reads an ASCII decimal short. |
static short |
readShort(java.lang.String prompt)
Reads an ASCII decimal short, after displaying given prompt. |
static java.lang.String |
readWord()
Reads a word. |
static java.lang.String |
readWord(java.lang.String prompt)
Reads a word, after displaying given prompt. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public Console()
Method Detail |
public static void main(java.lang.String[] args)
public static boolean checkError()
public static void flush()
public static void print(boolean value)
value
- the boolean to be printedpublic static void print(char value)
value
- the char to be printedpublic static void print(char[] value)
value
- the array of character to be printedpublic static void print(double value)
value
- the double to be printedpublic static void print(float value)
value
- the float to be printedpublic static void print(int value)
value
- the integer to be printedpublic static void print(long value)
value
- the long to be printedpublic static void print(java.lang.Object value)
value
- the object to be printedpublic static void print(java.lang.String value)
value
- the string to be printedpublic static void print(java.lang.String format, char value)
format
- the format stringvalue
- the character to printpublic static void print(java.lang.String format, double value)
format
- the format stringvalue
- the double to printpublic static void print(java.lang.String format, long value)
format
- the format stringvalue
- the double to printpublic static void print(java.lang.String format, java.lang.String value)
format
- the format stringvalue
- the string to printpublic static void println()
public static void println(boolean value)
value
- the boolean to be printedpublic static void println(char value)
value
- the character to be printedpublic static void println(double value)
value
- the double to be printedpublic static void println(float value)
value
- the float to be printedpublic static void println(int value)
value
- the integer to be printedpublic static void println(long value)
value
- the long integer to be printedpublic static void println(java.lang.Object value)
value
- the object to be printedpublic static void println(java.lang.String value)
value
- the string to be printedpublic static boolean bad()
public static boolean eof()
public static void flushLine()
public static boolean readBoolean()
public static boolean readBoolean(java.lang.String prompt)
prompt
- the prompt string to displaypublic static char readChar()
public static char readChar(java.lang.String prompt)
prompt
- the prompt string to displaypublic static double readDouble()
public static double readDouble(java.lang.String prompt)
prompt
- the prompt string to displaypublic static float readFloat()
public static float readFloat(java.lang.String prompt)
prompt
- the prompt string to displaypublic static int readInt()
public static int readInt(java.lang.String prompt)
prompt
- the prompt string to displaypublic static java.lang.String readLine()
public static java.lang.String readLine(java.lang.String prompt)
prompt
- the prompt string to displaypublic static long readLong()
public static long readLong(java.lang.String prompt)
prompt
- the prompt string to displaypublic static short readShort()
public static short readShort(java.lang.String prompt)
prompt
- the prompt string to displaypublic static java.lang.String readWord()
public static java.lang.String readWord(java.lang.String prompt)
prompt
- the prompt string to display
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |