# Console

public final class **Console** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
implements [Flushable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Flushable.html) Provides access to the console, if available. The system-wide instance can
be accessed via `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/System.html#console()`.

### Public Method Summary

|---|---|
| void | [flush](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Console.html#flush())() Flushes this stream by writing any buffered output to the underlying stream. |
| [Console](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Console.html) | [format](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Console.html#format(java.lang.String,%20java.lang.Object...))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) args) Writes a formatted string to the console using the specified format string and arguments. |
| [Console](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Console.html) | [printf](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Console.html#printf(java.lang.String,%20java.lang.Object...))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) args) Equivalent to `format(format, args)`. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [readLine](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Console.html#readLine())() Reads a line from the console. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [readLine](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Console.html#readLine(java.lang.String,%20java.lang.Object...))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) args) Reads a line from this console, using the specified prompt. |
| char\[\] | [readPassword](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Console.html#readPassword())() This method is unimplemented on Android. |
| char\[\] | [readPassword](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Console.html#readPassword(java.lang.String,%20java.lang.Object...))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) args) This method is unimplemented on Android. |
| [Reader](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Reader.html) | [reader](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Console.html#reader())() Returns the `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Reader.html` associated with this console. |
| [PrintWriter](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintWriter.html) | [writer](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Console.html#writer())() Returns the `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Writer.html` associated with this console. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.io.Flushable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Flushable.html)

|---|---|
| abstract void | [flush](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Flushable.html#flush())() Flushes this stream by writing any buffered output to the underlying stream. |

## Public Methods

#### public void
**flush**
()

Flushes this stream by writing any buffered output to the underlying
stream.

#### public [Console](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Console.html)
**format**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) args)

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

##### Parameters

| format | the format string (see `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html#format(java.lang.String,%20java.lang.Object...)`) |
| args | the list of arguments passed to the formatter. If there are more arguments than required by `format`, additional arguments are ignored. |
|---|---|

##### Returns

- the console instance.

#### public [Console](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Console.html)
**printf**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) args)

Equivalent to `format(format, args)`.

##### Parameters

| format |   |
| args |   |
|---|---|

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**readLine**
()

Reads a line from the console.

##### Returns

- the line, or null at EOF.

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**readLine**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) 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 | the format string (see `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html#format(java.lang.String,%20java.lang.Object...)`) |
| args | the list of arguments passed to the formatter. If there are more arguments than required by `format`, additional arguments are ignored. |
|---|---|

##### Returns

- the line, or null at EOF.

#### public char\[\]
**readPassword**
()

This method is unimplemented on Android.

#### public char\[\]
**readPassword**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) format, [Object...](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) args)

This method is unimplemented on Android.

##### Parameters

| format |   |
| args |   |
|---|---|

#### public [Reader](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Reader.html)
**reader**
()

Returns the `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Reader.html` associated with this console.

#### public [PrintWriter](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintWriter.html)
**writer**
()

Returns the `https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Writer.html` associated with this console.