Java Console API



public String readLine()

Reads a single line of text from the console.

Returns:A string containing the line read from the console, not including any line-termination characters, or null if an end of stream has been reached.Throws:IOError - If an I/O error occurs.


public char[] readPassword(String fmt, Object... args)

Provides a formatted prompt, then reads a password or passphrase from the console with echoing disabled.

Parameters:fmt - A format string as described in Format string syntax for the prompt text.args - Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by the Java Virtual Machine Specification.Returns:A character array containing the password or passphrase read from the console, not including any line-termination characters, or null if an end of stream has been reached.Throws:IllegalFormatException - If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.IOError - If an I/O error occurs.


public Console format(String fmt, Object... args)

Writes a formatted string to this console's output stream using the specified format string and arguments.

Parameters:fmt - A format string as described in Format string syntaxargs - Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by the Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.Returns:This consoleThrows:IllegalFormatException - If a format string contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of the formatter class specification.


ALL about SCJP = SCJP 1.6, mock, certification, scjp 1.5 , scjp questions, scjp books, scjp hand written notes, scjp dumps, scjp trainings, scjp video tutorials, scjp simulators etc.