Share via


Channels.NewWriter Method

Definition

Overloads

NewWriter(IWritableByteChannel, Charset)

Constructs a writer that encodes characters according to the given charset and writes the resulting bytes to the given channel.

NewWriter(IWritableByteChannel, String)

Constructs a writer that encodes characters according to the named charset and writes the resulting bytes to the given channel.

NewWriter(IWritableByteChannel, CharsetEncoder, Int32)

Constructs a writer that encodes characters using the given encoder and writes the resulting bytes to the given channel.

NewWriter(IWritableByteChannel, Charset)

Constructs a writer that encodes characters according to the given charset and writes the resulting bytes to the given channel.

[Android.Runtime.Register("newWriter", "(Ljava/nio/channels/WritableByteChannel;Ljava/nio/charset/Charset;)Ljava/io/Writer;", "", ApiSince=33)]
public static Java.IO.Writer? NewWriter (Java.Nio.Channels.IWritableByteChannel? ch, Java.Nio.Charset.Charset? charset);
[<Android.Runtime.Register("newWriter", "(Ljava/nio/channels/WritableByteChannel;Ljava/nio/charset/Charset;)Ljava/io/Writer;", "", ApiSince=33)>]
static member NewWriter : Java.Nio.Channels.IWritableByteChannel * Java.Nio.Charset.Charset -> Java.IO.Writer

Parameters

ch
IWritableByteChannel

The channel to which bytes will be written

charset
Charset

The charset to be used

Returns

A new writer

Attributes

Remarks

Constructs a writer that encodes characters according to the given charset and writes the resulting bytes to the given channel.

An invocation of this method of the form

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

behaves in exactly the same way as the expression

{@code
                Channels.newWriter(ch, Charset.forName(csName).newEncoder(), -1)
            } 

The writer'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.CharsetEncoder should be used.

Java documentation for java.nio.channels.Channels.newWriter(java.nio.channels.WritableByteChannel, 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

NewWriter(IWritableByteChannel, String)

Constructs a writer that encodes characters according to the named charset and writes the resulting bytes to the given channel.

[Android.Runtime.Register("newWriter", "(Ljava/nio/channels/WritableByteChannel;Ljava/lang/String;)Ljava/io/Writer;", "")]
public static Java.IO.Writer? NewWriter (Java.Nio.Channels.IWritableByteChannel? ch, string? csName);
[<Android.Runtime.Register("newWriter", "(Ljava/nio/channels/WritableByteChannel;Ljava/lang/String;)Ljava/io/Writer;", "")>]
static member NewWriter : Java.Nio.Channels.IWritableByteChannel * string -> Java.IO.Writer

Parameters

ch
IWritableByteChannel

The channel to which bytes will be written

csName
String

The name of the charset to be used

Returns

A new writer

Attributes

Exceptions

if the given charset name is not supported.

Remarks

Constructs a writer that encodes characters according to the named charset and writes the resulting bytes to the given channel.

An invocation of this method of the form

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

behaves in exactly the same way as the expression

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

Java documentation for java.nio.channels.Channels.newWriter(java.nio.channels.WritableByteChannel, 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

NewWriter(IWritableByteChannel, CharsetEncoder, Int32)

Constructs a writer that encodes characters using the given encoder and writes the resulting bytes to the given channel.

[Android.Runtime.Register("newWriter", "(Ljava/nio/channels/WritableByteChannel;Ljava/nio/charset/CharsetEncoder;I)Ljava/io/Writer;", "")]
public static Java.IO.Writer? NewWriter (Java.Nio.Channels.IWritableByteChannel? ch, Java.Nio.Charset.CharsetEncoder? enc, int minBufferCap);
[<Android.Runtime.Register("newWriter", "(Ljava/nio/channels/WritableByteChannel;Ljava/nio/charset/CharsetEncoder;I)Ljava/io/Writer;", "")>]
static member NewWriter : Java.Nio.Channels.IWritableByteChannel * Java.Nio.Charset.CharsetEncoder * int -> Java.IO.Writer

Parameters

ch
IWritableByteChannel

The channel to which bytes will be written

enc
CharsetEncoder

The charset encoder 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 writer

Attributes

Remarks

Constructs a writer that encodes characters using the given encoder and writes the resulting bytes to the given channel.

The resulting stream will contain an internal output buffer of at least minBufferCap bytes. The stream's write methods will, as needed, flush the buffer by writing bytes to the underlying channel; if the channel is in non-blocking mode when bytes are to be written then an IllegalBlockingModeException will be thrown. The resulting stream will not otherwise be buffered. Closing the stream will in turn cause the channel to be closed.

Java documentation for java.nio.channels.Channels.newWriter(java.nio.channels.WritableByteChannel, java.nio.charset.CharsetEncoder, 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