Share via


Channels.NewReader Method

Definition

Overloads

NewReader(IReadableByteChannel, Charset)

Constructs a reader that decodes bytes from the given channel according to the given charset.

NewReader(IReadableByteChannel, String)

Constructs a reader that decodes bytes from the given channel according to the named charset.

NewReader(IReadableByteChannel, CharsetDecoder, Int32)

Constructs a reader that decodes bytes from the given channel using the given decoder.

NewReader(IReadableByteChannel, Charset)

Constructs a reader that decodes bytes from the given channel according to the given charset.

[Android.Runtime.Register("newReader", "(Ljava/nio/channels/ReadableByteChannel;Ljava/nio/charset/Charset;)Ljava/io/Reader;", "", ApiSince=33)]
public static Java.IO.Reader? NewReader (Java.Nio.Channels.IReadableByteChannel? ch, Java.Nio.Charset.Charset? charset);
[<Android.Runtime.Register("newReader", "(Ljava/nio/channels/ReadableByteChannel;Ljava/nio/charset/Charset;)Ljava/io/Reader;", "", ApiSince=33)>]
static member NewReader : Java.Nio.Channels.IReadableByteChannel * Java.Nio.Charset.Charset -> Java.IO.Reader

Parameters

ch
IReadableByteChannel

The channel from which bytes will be read

charset
Charset

The charset to be used

Returns

A new reader

Attributes

Remarks

Constructs a reader that decodes bytes from the given channel according to the given charset.

An invocation of this method of the form

{@code
                Channels.newReader(ch, charset)
            } 

behaves in exactly the same way as the expression

{@code
                Channels.newReader(ch, Charset.forName(csName).newDecoder(), -1)
            } 

The reader's default action for malformed-input and unmappable-character errors is to java.nio.charset.CodingErrorAction#REPORT report them. When more control over the error handling is required, the constructor that takes a java.nio.charset.CharsetDecoder should be used.

Java documentation for java.nio.channels.Channels.newReader(java.nio.channels.ReadableByteChannel, java.nio.charset.Charset).

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

NewReader(IReadableByteChannel, String)

Constructs a reader that decodes bytes from the given channel according to the named charset.

[Android.Runtime.Register("newReader", "(Ljava/nio/channels/ReadableByteChannel;Ljava/lang/String;)Ljava/io/Reader;", "")]
public static Java.IO.Reader? NewReader (Java.Nio.Channels.IReadableByteChannel? ch, string? csName);
[<Android.Runtime.Register("newReader", "(Ljava/nio/channels/ReadableByteChannel;Ljava/lang/String;)Ljava/io/Reader;", "")>]
static member NewReader : Java.Nio.Channels.IReadableByteChannel * string -> Java.IO.Reader

Parameters

ch
IReadableByteChannel

The channel from which bytes will be read

csName
String

The name of the charset to be used

Returns

A new reader

Attributes

Exceptions

if the given charset name is not supported.

Remarks

Constructs a reader that decodes bytes from the given channel according to the named charset.

An invocation of this method of the form

{@code
                Channels.newReader(ch, csname)
            } 

behaves in exactly the same way as the expression

{@code
                Channels.newReader(ch, Charset.forName(csName))
            } 

Java documentation for java.nio.channels.Channels.newReader(java.nio.channels.ReadableByteChannel, java.lang.String).

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

NewReader(IReadableByteChannel, CharsetDecoder, Int32)

Constructs a reader that decodes bytes from the given channel using the given decoder.

[Android.Runtime.Register("newReader", "(Ljava/nio/channels/ReadableByteChannel;Ljava/nio/charset/CharsetDecoder;I)Ljava/io/Reader;", "")]
public static Java.IO.Reader? NewReader (Java.Nio.Channels.IReadableByteChannel? ch, Java.Nio.Charset.CharsetDecoder? dec, int minBufferCap);
[<Android.Runtime.Register("newReader", "(Ljava/nio/channels/ReadableByteChannel;Ljava/nio/charset/CharsetDecoder;I)Ljava/io/Reader;", "")>]
static member NewReader : Java.Nio.Channels.IReadableByteChannel * Java.Nio.Charset.CharsetDecoder * int -> Java.IO.Reader

Parameters

ch
IReadableByteChannel

The channel from which bytes will be read

dec
CharsetDecoder

The charset decoder to be used

minBufferCap
Int32

The minimum capacity of the internal byte buffer, or -1 if an implementation-dependent default capacity is to be used

Returns

A new reader

Attributes

Remarks

Constructs a reader that decodes bytes from the given channel using the given decoder.

The resulting stream will contain an internal input buffer of at least minBufferCap bytes. The stream's read methods will, as needed, fill the buffer by reading bytes from the underlying channel; if the channel is in non-blocking mode when bytes are to be read then an IllegalBlockingModeException will be thrown. The resulting stream will not otherwise be buffered, and it will not support the Reader#mark mark or Reader#reset reset methods. Closing the stream will in turn cause the channel to be closed.

Java documentation for java.nio.channels.Channels.newReader(java.nio.channels.ReadableByteChannel, java.nio.charset.CharsetDecoder, int).

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