Functions of ballerina.io package
public function <ByteChannel channel> close()
Function to close a byte channel
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | ByteChannel | The ByteChannel to be closed |
public function <CharacterChannel channel> closeCharacterChannel()
Function to close a character channel
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | CharacterChannel | The CharacterChannel to be closed |
public function <TextRecordChannel channel> closeTextRecordChannel()
Function to close the text record channel
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | TextRecordChannel | The TextRecordChannel to be closed |
public function <ByteChannel channel> readAllBytes() (blob, int)
Function to read all bytes in the given I/O source
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | ByteChannel |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
blob | all bytes read from the channel | |
int |
public function <CharacterChannel channel> readAllCharacters() (string)
Function to read all characters in the give I/O source
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | CharacterChannel |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | all characters read |
public function <ByteChannel channel> readBytes(int numberOfBytes) (blob, int)
Function to read bytes
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | ByteChannel | The ByteChannel to read bytes from |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
numberOfBytes | int | Number of bytes which should be read |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
blob | The bytes which were read | |
int | Number of bytes read |
public function <CharacterChannel channel> readCharacters(int numberOfChars) (string)
Function to read characters
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | CharacterChannel | The CharacterChannel to read characters from |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
numberOfChars | int | Number of characters which should be read |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The character sequence which was read |
public function <TextRecordChannel channel> readTextRecord() (string[])
Function to read text records
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | TextRecordChannel | The TextRecordChannel to read text records from |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string[] | Fields listed in the record |
public function <ByteChannel channel> toCharacterChannel(string encoding) (CharacterChannel)
Function to convert a ByteChannel to CharacterChannel
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | ByteChannel | The ByteChannel to be converted |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
encoding | string | The charset/encoding of the content (i.e UTF-8, ASCII) |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
CharacterChannel | CharacterChannel converted from ByteChannel |
public function <CharacterChannel channel> toTextRecordChannel(string recordSeparator, string fieldSeparator) (TextRecordChannel)
Function to convert a CharacterChannel to TextRecordChannel
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | CharacterChannel | The CharacterChannel to be converted |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
recordSeparator | string | Terminating expression to distinguish between records |
fieldSeparator | string | Terminating expression to distinguish between fields |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
TextRecordChannel | TextRecordChannel converted from CharacterChannel |
public function <ByteChannel channel> writeBytes(blob content, int startOffset) (int)
Function to write bytes
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | ByteChannel | The ByteChannel to write bytes to |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
content | blob | Bytes which should be written |
startOffset | int | If the bytes need to be written with an offset, the value of that offset |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | Number of bytes written |
public function <CharacterChannel channel> writeCharacters(string content, int startOffset) (int)
Function to write characters
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | CharacterChannel | The CharacterChannel to write characters to |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
content | string | Text content which should be written |
startOffset | int | If the content needs to be written with an offset, the value of that offset |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | Number of characters written |
public function <TextRecordChannel channel> writeTextRecord(string[] records)
Function to write text records
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | TextRecordChannel | The TextRecordChannel to write text records to |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
records | string[] | Fields which are included in the record |
Structs of ballerina.io package
public struct ByteChannel
Ballerina ByteChannel represents a channel which will allow I/O operations to be done
public struct CharacterChannel
Ballerina CharacterChannel represents a channel which will allow to read/write characters
public struct TextRecordChannel
Ballerina TextRecordChannel represents a channel which will allow to read/write text records