Functions of ballerina.io package
public function <ByteChannel channel> close()
Function to close the byte channel
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | ByteChannel |
public function <CharacterChannel channel> closeCharacterChannel()
Function to close character channel
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | CharacterChannel |
public function <TextRecordChannel channel> closeTextRecordChannel()
Function to close the text record channel
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | TextRecordChannel |
public function <ByteChannel channel> readBytes(int numberOfBytes) (blob, int)
Function to read bytes
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | ByteChannel | numberOfBytes: number of bytes which should be read |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
numberOfBytes | int | number of bytes which should be read |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
blob | blob: the bytes which were read | |
int | blob: the bytes which were read |
public function <CharacterChannel channel> readCharacters(int numberOfChars) (string)
Function to read characters
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | CharacterChannel | numberOfChars: number of characters which should be read |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
numberOfChars | int | number of characters which should be read |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | the characters which will be read |
public function <TextRecordChannel channel> readTextRecord() (string[])
Function to read text records
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | TextRecordChannel |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string[] | Fields listed in the record |
public function <ByteChannel channel> toCharacterChannel(string encoding) (CharacterChannel)
Function to convert ByteChannel to CharacterChannel
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | ByteChannel | encoding: the charset/encoding of the content (i.e UTF-8, ASCCI) |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
encoding | string | the charset/encoding of the content (i.e UTF-8, ASCCI) |
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 CharacterChannel to TextRecordChannel
Receiver:
Receiver Name | Data Type | Description |
---|---|---|
channel | CharacterChannel | recordSeparator: terminating expression to distingush between records |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
recordSeparator | string | terminating expression to distingush between records |
fieldSeparator | string | terminating expression to ditingish between feilds |
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 | content: bytes which should be written |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
content | blob | bytes which should be written |
startOffset | int | content: bytes which should be written |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | 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 | content: text content which should be written |
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 |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | 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 | records: feilds which are included in the record |
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
records | string[] | feilds 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 reprsents a channel which will allow reading/writing characters
public struct TextRecordChannel
Ballerina TextRecordChannel represents a channel which will allow read/write text records