Object - io : WritableCharacterChannel

Represents a channel which could be used to write characters through a given WritableCharacterChannel.

Constructor

__init

(WritableByteChannel bChannel, string charset)

  • bChannel WritableByteChannel
  • The WritableByteChannel, which would be used to write the characters

  • charset string
  • The character set, which would be used to encode the given bytes to characters

Methods

Writes a given sequence of characters (string).
Writes a given JSON to the given channel.
Writes a given XML to the channel.
Closes a given WritableCharacterChannel channel.

write

(string content, int startOffset)

returns int | Error

Writes a given sequence of characters (string).

 int|io:Error result = writableCharChannel.write("Content", 0);

Parameters

  • content string
  • Content, which should be written

  • startOffset int
  • Number of characters, which should be offset when writing the content

  • Return Type

    (int | Error)
  • Content length that written or else io:Error

writeJson

(json content)

returns Error?

Writes a given JSON to the given channel.

 io:Error? err = writableCharChannel.writeJson(inputJson, 0);

Parameters

  • content json
  • The JSON, which should be written

  • Return Type

    (Error?)
  • If an io:Error occurred while writing

writeXml

(xml content)

returns Error?

Writes a given XML to the channel.

 io:Error? err = writableCharChannel.writeXml(inputXml, 0);

Parameters

  • content xml
  • The XML, which should be written

  • Return Type

    (Error?)
  • () or else io:Error if any error occurred

close

()

returns Error?

Closes a given WritableCharacterChannel channel.

 io:Error err = writableCharChannel.close();

  • Return Type

    (Error?)
  • () or else an io:Error if any error occurred