Skip to content

Most visited

Recently visited

navigation
Added in API level 9

Console

public final class Console
extends Object implements Flushable

java.lang.Object
   ↳ java.io.Console


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.

Inherited methods

From class java.lang.Object
From interface java.io.Flushable

Public methods

flush

Added in API level 9
void flush ()

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

format

Added in API level 9
Console format (String format, 
                Object... args)

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.

printf

Added in API level 9
Console printf (String format, 
                Object... args)

Equivalent to format(format, args).

Parameters
format String
args Object
Returns
Console

readLine

Added in API level 9
String readLine (String format, 
                Object... args)

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.

readLine

Added in API level 9
String readLine ()

Reads a line from the console.

Returns
String the line, or null at EOF.

readPassword

Added in API level 9
char[] readPassword (String format, 
                Object... args)

This method is unimplemented on Android.

Parameters
format String
args Object
Returns
char[]

readPassword

Added in API level 9
char[] readPassword ()

This method is unimplemented on Android.

Returns
char[]

reader

Added in API level 9
Reader reader ()

Returns the Reader associated with this console.

Returns
Reader

writer

Added in API level 9
PrintWriter writer ()

Returns the Writer associated with this console.

Returns
PrintWriter
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.