public final class Console extends Object implements Flushable
System.console().| Modifier and Type | Method and Description |
|---|---|
void |
flush()
Flushes the object by writing out any buffered data to the underlying
output.
|
Console |
format(String format,
Object... args)
Writes a formatted string to the console using
the specified format string and arguments.
|
static Console |
getConsole()
Secret accessor for
System.console. |
Console |
printf(String format,
Object... args)
Equivalent to
format(format, args). |
Reader |
reader()
Returns the
Reader associated with this console. |
String |
readLine()
Reads a line from the console.
|
String |
readLine(String format,
Object... args)
Reads a line from this console, using the specified prompt.
|
char[] |
readPassword()
This method is unimplemented on Android.
|
char[] |
readPassword(String format,
Object... args)
This method is unimplemented on Android.
|
PrintWriter |
writer()
Returns the
Writer associated with this console. |
public static Console getConsole()
System.console.public void flush()
Flushablepublic Console format(String format, Object... args)
format - the format string (see Formatter.format(java.lang.String, java.lang.Object...))args - the list of arguments passed to the formatter. If there are
more arguments than required by format,
additional arguments are ignored.public String readLine()
public String readLine(String format, Object... args)
% characters, you must use the format string "%s"
and pass the actual prompt as a parameter.format - the format string (see Formatter.format(java.lang.String, java.lang.Object...))args - the list of arguments passed to the formatter. If there are
more arguments than required by format,
additional arguments are ignored.public char[] readPassword()
public char[] readPassword(String format, Object... args)
public PrintWriter writer()
Writer associated with this console.