Share via


Console.Reader Method

Definition

Retrieves the unique java.io.Reader Reader object associated with this console.

[Android.Runtime.Register("reader", "()Ljava/io/Reader;", "")]
public Java.IO.Reader? Reader ();
[<Android.Runtime.Register("reader", "()Ljava/io/Reader;", "")>]
member this.Reader : unit -> Java.IO.Reader

Returns

The reader associated with this console

Attributes

Remarks

Retrieves the unique java.io.Reader Reader object associated with this console.

This method is intended to be used by sophisticated applications, for example, a java.util.Scanner object which utilizes the rich parsing/scanning functionality provided by the Scanner: <blockquote>

Console con = System.console();
            if (con != null) {
                Scanner sc = new Scanner(con.reader());
                ...
            }

</blockquote>

For simple applications requiring only line-oriented reading, use #readLine.

The bulk read operations java.io.Reader#read(char[]) read(char[]) , java.io.Reader#read(char[], int, int) read(char[], int, int) and java.io.Reader#read(java.nio.CharBuffer) read(java.nio.CharBuffer) on the returned object will not read in characters beyond the line bound for each invocation, even if the destination buffer has space for more characters. The Reader's read methods may block if a line bound has not been entered or reached on the console's input device. A line bound is considered to be any one of a line feed ('\n'), a carriage return ('\r'), a carriage return followed immediately by a linefeed, or an end of stream.

Java documentation for java.io.Console.reader().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to