Object -
io
:
ReadableCharacterChannel
Represents a channel, which could be used to read characters through a given ReadableByteChannel.
Constructor
__init
(ReadableByteChannel byteChannel, string charset)
- byteChannel ReadableByteChannel
-
The
ReadableByteChannel
, which would be used to read the characters
- charset string
-
The character set, which would be used to encode/decode the given bytes to characters
Methods
Reads a given number of characters. This will attempt to read up to the
numberOfChars
characters of the channel.
An io:EofError
will return once the channel reaches the end.
string|io:Error result = readableCharChannel.read(1000);
Reads a JSON from the given channel.
json|io:Error result = readableCharChannel.readJson();
Reads an XML from the given channel.
json|io:Error result = readableCharChannel.readXml();
Closes a given character channel.
io:Error? err = readableCharChannel.close();
Reads a given number of characters. This will attempt to read up to the
numberOfChars
characters of the channel.
An io:EofError
will return once the channel reaches the end.
string|io:Error result = readableCharChannel.read(1000);
Parameters
- numberOfChars int
-
Number of characters, which should be read
-
Return Type
(string | Error) Content, which is read, an
EofError
once the channel reaches the end or else anio:Error
Reads a JSON from the given channel.
json|io:Error result = readableCharChannel.readJson();
-
Return Type
(json | Error) The read JSON string or else an
io:Error
Reads an XML from the given channel.
json|io:Error result = readableCharChannel.readXml();
-
Return Type
(xml | Error) The read XML or else an
io:Error