scala

object Console

[source: scala/Console.scala]

object Console
extends AnyRef
The Console object implements functionality for printing Scala values on the terminal. There are also functions for reading specific values. Console also defines constants for marking up text on ANSI terminals.
Author
Matthias Zenger
Version
1.0, 03/09/2003
Value Summary
final val BLACK : java.lang.String = "\033[30m"
final val BLACK_B : java.lang.String = "\033[40m"
final val BLINK : java.lang.String = "\033[5m"
final val BLUE : java.lang.String = "\033[34m"
final val BLUE_B : java.lang.String = "\033[44m"
final val BOLD : java.lang.String = "\033[1m"
final val CYAN : java.lang.String = "\033[36m"
final val CYAN_B : java.lang.String = "\033[46m"
final val GREEN : java.lang.String = "\033[32m"
final val GREEN_B : java.lang.String = "\033[42m"
final val INVISIBLE : java.lang.String = "\033[8m"
final val MAGENTA : java.lang.String = "\033[35m"
final val MAGENTA_B : java.lang.String = "\033[45m"
final val RED : java.lang.String = "\033[31m"
final val RED_B : java.lang.String = "\033[41m"
final val RESET : java.lang.String = "\033[0m"
final val REVERSED : java.lang.String = "\033[7m"
final val UNDERLINED : java.lang.String = "\033[4m"
final val WHITE : java.lang.String = "\033[37m"
final val WHITE_B : java.lang.String = "\033[47m"
final val YELLOW : java.lang.String = "\033[33m"
final val YELLOW_B : java.lang.String = "\033[43m"
val err : java.io.PrintStream
Method Summary
def flush : Unit
Flush the output stream. This function is required when partial output (i.e. output not terminated by a new line character) has to be made visible on the terminal.
def format (text : java.lang.String, args : Any*) : Unit
def in : java.io.BufferedReader
def out : java.io.PrintStream
def print (obj : Any) : Unit
Print an object on the terminal.
def printf (text : java.lang.String, args : Any*) : Unit
def println : Unit
Print a new line character on the terminal.
def println (x : Any) : Unit
Print out an object followed by a new line character.
def readBoolean : Boolean
Read a boolean value from the terminal. Throws EOFException if the end of the input stream has been reached.
def readByte : Byte
Read a byte value from the terminal. Throws EOFException if the end of the input stream has been reached.
def readChar : Char
Read a char value from the terminal. Throws EOFException if the end of the input stream has been reached.
def readDouble : Double
Read a double value from the terminal. Throws EOFException if the end of the input stream has been reached.
def readFloat : Float
Read a float value from the terminal. Throws EOFException if the end of the input stream has been reached.
def readInt : Int
Read an int value from the terminal. Throws EOFException if the end of the input stream has been reached.
def readLine (text : java.lang.String, args : Any*) : java.lang.String
Print a formatted text and read a full line from the terminal. Returns null if the end of the input stream has been reached.
def readLine : java.lang.String
Read a full line from the terminal. Returns null if the end of the input stream has been reached.
def readLong : Long
Read an int value from the terminal. Throws EOFException if the end of the input stream has been reached.
def readShort : Short
Read a short value from the terminal. Throws EOFException if the end of the input stream has been reached.
def readf (format : java.lang.String) : List[Any]
Read in some structured input, specified by a format specifier. See class java.text.MessageFormat for details of the format specification. Throws EOFException if the end of the input stream has been reached.
def readf1 (format : java.lang.String) : Any
Read in some structured input, specified by a format specifier. Opposed to readf, this function only returns the first value extracted from the input according to the format specification.
def readf2 (format : java.lang.String) : (Any, Any)
Read in some structured input, specified by a format specifier. Opposed to readf, this function only returns the first two values extracted from the input according to the format specification.
def readf3 (format : java.lang.String) : (Any, Any, Any)
Read in some structured input, specified by a format specifier. Opposed to readf, this function only returns the first three values extracted from the input according to the format specification.
def setIn (in : java.io.InputStream) : Unit
Set the default input stream.
def setIn (reader : java.io.Reader) : Unit
Set the default input stream.
def setOut (out : java.io.PrintStream) : Unit
Set the default output stream.
def setOut (out : java.io.OutputStream) : Unit
Set the default output stream. @param@ out the new output stream.
def withIn [T](in : java.io.InputStream)(thunk : => T) : T
Set the default input stream for the duration of execution of one thunk.
def withIn [T](reader : java.io.Reader)(thunk : => T) : T
Set the default input stream for the duration of execution of one thunk.
def withOut [T](out : java.io.OutputStream)(thunk : => T) : T
Set the default output stream for the duration of execution of one thunk.
def withOut [T](out : java.io.PrintStream)(thunk : => T) : T
Set the default output stream for the duration of execution of one thunk.
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Value Details
final val BLACK : java.lang.String

final val RED : java.lang.String

final val GREEN : java.lang.String

final val YELLOW : java.lang.String

final val BLUE : java.lang.String

final val MAGENTA : java.lang.String

final val CYAN : java.lang.String

final val WHITE : java.lang.String

final val BLACK_B : java.lang.String

final val RED_B : java.lang.String

final val GREEN_B : java.lang.String

final val YELLOW_B : java.lang.String

final val BLUE_B : java.lang.String

final val MAGENTA_B : java.lang.String

final val CYAN_B : java.lang.String

final val WHITE_B : java.lang.String

final val RESET : java.lang.String

final val BOLD : java.lang.String

final val UNDERLINED : java.lang.String

final val BLINK : java.lang.String

final val REVERSED : java.lang.String

final val INVISIBLE : java.lang.String

val err : java.io.PrintStream

Method Details
def out : java.io.PrintStream

def in : java.io.BufferedReader

def setOut(out : java.io.PrintStream) : Unit
Set the default output stream.
Parameters
out - the new output stream.

def withOut[T](out : java.io.PrintStream)(thunk : => T) : T
Set the default output stream for the duration of execution of one thunk.
Parameters
out - the new output stream.
thunk - the code to execute with the new output stream active
Returns
...

def setOut(out : java.io.OutputStream) : Unit
Set the default output stream. @param@ out the new output stream.

def withOut[T](out : java.io.OutputStream)(thunk : => T) : T
Set the default output stream for the duration of execution of one thunk.
Parameters
out - the new output stream.
thunk - the code to execute with the new output stream active
Returns
...

def setIn(reader : java.io.Reader) : Unit
Set the default input stream.
Parameters
reader - specifies the new input stream.

def withIn[T](reader : java.io.Reader)(thunk : => T) : T
Set the default input stream for the duration of execution of one thunk.
Parameters
in - the new input stream.
thunk - the code to execute with the new input stream active

def setIn(in : java.io.InputStream) : Unit
Set the default input stream.
Parameters
in - the new input stream.

def withIn[T](in : java.io.InputStream)(thunk : => T) : T
Set the default input stream for the duration of execution of one thunk.
Parameters
in - the new input stream.
thunk - the code to execute with the new input stream active

def print(obj : Any) : Unit
Print an object on the terminal.
Parameters
obj - the object to print.

def flush : Unit
Flush the output stream. This function is required when partial output (i.e. output not terminated by a new line character) has to be made visible on the terminal.

def println : Unit
Print a new line character on the terminal.

def println(x : Any) : Unit
Print out an object followed by a new line character.
Parameters
x - the object to print.

def printf(text : java.lang.String, args : Any*) : Unit

Prints its arguments as a formatted string, based on a string pattern (in a fashion similar to printf in C).

The interpretation of the formatting patterns is described in java.util.Formatter.

Parameters
text - the pattern for formatting the arguments.
args - the arguments used to instantiating the pattern.
Throws
java.lang.IllegalArgumentException -

@deprecated

def format(text : java.lang.String, args : Any*) : Unit
See Also
Console.printf.
Deprecated
For console output, use Console.printf. For String formatting, RichString's format method.

def readLine : java.lang.String
Read a full line from the terminal. Returns null if the end of the input stream has been reached.
Returns
the string read from the terminal.

def readLine(text : java.lang.String, args : Any*) : java.lang.String
Print a formatted text and read a full line from the terminal. Returns null if the end of the input stream has been reached.
Parameters
text - the format of the text to print out.
args - the parameters used to instantiate the format.
Returns
the string read from the terminal.

def readBoolean : Boolean
Read a boolean value from the terminal. Throws EOFException if the end of the input stream has been reached.
Returns
the boolean value read from the terminal.
Throws
java.io.EOFException -

def readByte : Byte
Read a byte value from the terminal. Throws EOFException if the end of the input stream has been reached.
Throws
java.io.EOFException -

def readShort : Short
Read a short value from the terminal. Throws EOFException if the end of the input stream has been reached.
Throws
java.io.EOFException -

def readChar : Char
Read a char value from the terminal. Throws EOFException if the end of the input stream has been reached.
Throws
java.io.EOFException -

def readInt : Int
Read an int value from the terminal. Throws EOFException if the end of the input stream has been reached.
Throws
java.io.EOFException -

def readLong : Long
Read an int value from the terminal. Throws EOFException if the end of the input stream has been reached.
Throws
java.io.EOFException -

def readFloat : Float
Read a float value from the terminal. Throws EOFException if the end of the input stream has been reached.
Throws
java.io.EOFException -

def readDouble : Double
Read a double value from the terminal. Throws EOFException if the end of the input stream has been reached.
Throws
java.io.EOFException -

def readf(format : java.lang.String) : List[Any]
Read in some structured input, specified by a format specifier. See class java.text.MessageFormat for details of the format specification. Throws EOFException if the end of the input stream has been reached.
Parameters
format - the format of the input.
Returns
a list of all extracted values.
Throws
java.io.EOFException -

def readf1(format : java.lang.String) : Any
Read in some structured input, specified by a format specifier. Opposed to readf, this function only returns the first value extracted from the input according to the format specification.
Parameters
format - ...
Returns
...

def readf2(format : java.lang.String) : (Any, Any)
Read in some structured input, specified by a format specifier. Opposed to readf, this function only returns the first two values extracted from the input according to the format specification.
Parameters
format - ...
Returns
...

def readf3(format : java.lang.String) : (Any, Any, Any)
Read in some structured input, specified by a format specifier. Opposed to readf, this function only returns the first three values extracted from the input according to the format specification.
Parameters
format - ...
Returns
...