public abstract class Channel extends AbstractChannel
Represents Ballerina Byte Channel.
Allows reading/writing bytes to perform I/O operations.
The bytes are read through the channel into the buffer. This will manage the buffer and the channel to deliver bytes I/O reading/writing APIs.
Constructor and Description |
---|
Channel(ByteChannel channel,
int size) |
Modifier and Type | Method and Description |
---|---|
byte[] |
read(int numberOfBytes)
Reads specified amount of bytes from a given channel.
|
byte[] |
readAll()
Reads all bytes from the I/O source.
|
int |
write(byte[] content,
int startOffset)
Writes bytes to channel.
|
close, transfer
public Channel(ByteChannel channel, int size) throws BallerinaIOException
BallerinaIOException
public byte[] read(int numberOfBytes) throws BallerinaIOException
Reads specified amount of bytes from a given channel.
Each time this method is called the data will be retrieved from the channels last read position.
Note : This operation cannot be called in parallel invocations since the underlying ByteBuffer and the channel are not synchronous.
numberOfBytes
- the number of bytes required.BallerinaIOException
- during I/O error.public byte[] readAll() throws BallerinaException
BallerinaException
- during I/O error.public int write(byte[] content, int startOffset) throws BallerinaException
content
- the data which will be written.startOffset
- if the data should be written from an offset (starting byte position).BallerinaException
Copyright © 2018 WSO2. All rights reserved.