Android APIs
public final class

Console

extends Object
implements Flushable
java.lang.Object
   ↳ java.io.Console

Class Overview

Provides access to the console, if available. The system-wide instance can be accessed via console().

Summary

Public Methods
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.
Console printf(String format, Object... args)
Equivalent to format(format, args).
String readLine(String format, Object... args)
Reads a line from this console, using the specified prompt.
String readLine()
Reads a line from the console.
char[] readPassword(String format, Object... args)
This method is unimplemented on Android.
char[] readPassword()
This method is unimplemented on Android.
Reader reader()
Returns the Reader associated with this console.
PrintWriter writer()
Returns the Writer associated with this console.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.io.Flushable

Public Methods

public void flush ()

Added in API level 9

Flushes the object by writing out any buffered data to the underlying output.

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

Added in API level 9

Writes a formatted string to the console using the specified format string and arguments.

Parameters
format String: the format string (see format(String, Object...))
args Object: the list of arguments passed to the formatter. If there are more arguments than required by format, additional arguments are ignored.
Returns
Console the console instance.

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

Added in API level 9

Equivalent to format(format, args).

Parameters
format String
args Object
Returns
Console

public String readLine (String format, Object... args)

Added in API level 9

Reads a line from this console, using the specified prompt. The prompt is given as a format string and optional arguments. Note that this can be a source of errors: if it is possible that your prompt contains % characters, you must use the format string "%s" and pass the actual prompt as a parameter.

Parameters
format String: the format string (see format(String, Object...))
args Object: the list of arguments passed to the formatter. If there are more arguments than required by format, additional arguments are ignored.
Returns
String the line, or null at EOF.

public String readLine ()

Added in API level 9

Reads a line from the console.

Returns
String the line, or null at EOF.

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

Added in API level 9

This method is unimplemented on Android.

Parameters
format String
args Object
Returns
char[]

public char[] readPassword ()

Added in API level 9

This method is unimplemented on Android.

Returns
char[]

public Reader reader ()

Added in API level 9

Returns the Reader associated with this console.

Returns
Reader

public PrintWriter writer ()

Added in API level 9

Returns the Writer associated with this console.

Returns
PrintWriter