Ballerina API Documentation

Functions of ballerina.io package

public function <ByteChannel channel> close()

Function to close a byte channel

Receiver:

Receiver NameData TypeDescription
channelByteChannelThe ByteChannel to be closed

public function <CharacterChannel channel> closeCharacterChannel()

Function to close a character channel

Receiver:

Receiver NameData TypeDescription
channelCharacterChannelThe CharacterChannel to be closed

public function <TextRecordChannel channel> closeTextRecordChannel()

Function to close the text record channel

Receiver:

Receiver NameData TypeDescription
channelTextRecordChannelThe TextRecordChannel to be closed

public function <ByteChannel channel> readAllBytes() (blob, int)

Function to read all bytes in the given I/O source

Receiver:

Receiver NameData TypeDescription
channelByteChannel

Return Parameters:

Return VariableData TypeDescription
bloball 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 NameData TypeDescription
channelCharacterChannel

Return Parameters:

Return VariableData TypeDescription
stringall characters read

public function <ByteChannel channel> readBytes(int numberOfBytes) (blob, int)

Function to read bytes

Receiver:

Receiver NameData TypeDescription
channelByteChannelThe ByteChannel to read bytes from

Parameters:

Parameter NameData TypeDescription
numberOfBytesintNumber of bytes which should be read

Return Parameters:

Return VariableData TypeDescription
blobThe bytes which were read
intNumber of bytes read

public function <CharacterChannel channel> readCharacters(int numberOfChars) (string)

Function to read characters

Receiver:

Receiver NameData TypeDescription
channelCharacterChannelThe CharacterChannel to read characters from

Parameters:

Parameter NameData TypeDescription
numberOfCharsintNumber of characters which should be read

Return Parameters:

Return VariableData TypeDescription
stringThe character sequence which was read

public function <TextRecordChannel channel> readTextRecord() (string[])

Function to read text records

Receiver:

Receiver NameData TypeDescription
channelTextRecordChannelThe TextRecordChannel to read text records from

Return Parameters:

Return VariableData TypeDescription
string[]Fields listed in the record

public function <ByteChannel channel> toCharacterChannel(string encoding) (CharacterChannel)

Function to convert a ByteChannel to CharacterChannel

Receiver:

Receiver NameData TypeDescription
channelByteChannelThe ByteChannel to be converted

Parameters:

Parameter NameData TypeDescription
encodingstringThe charset/encoding of the content (i.e UTF-8, ASCII)

Return Parameters:

Return VariableData TypeDescription
CharacterChannelCharacterChannel converted from ByteChannel

public function <CharacterChannel channel> toTextRecordChannel(string recordSeparator, string fieldSeparator) (TextRecordChannel)

Function to convert a CharacterChannel to TextRecordChannel

Receiver:

Receiver NameData TypeDescription
channelCharacterChannelThe CharacterChannel to be converted

Parameters:

Parameter NameData TypeDescription
recordSeparatorstringTerminating expression to distinguish between records
fieldSeparatorstringTerminating expression to distinguish between fields

Return Parameters:

Return VariableData TypeDescription
TextRecordChannelTextRecordChannel converted from CharacterChannel

public function <ByteChannel channel> writeBytes(blob content, int startOffset) (int)

Function to write bytes

Receiver:

Receiver NameData TypeDescription
channelByteChannelThe ByteChannel to write bytes to

Parameters:

Parameter NameData TypeDescription
contentblobBytes which should be written
startOffsetintIf the bytes need to be written with an offset, the value of that offset

Return Parameters:

Return VariableData TypeDescription
intNumber of bytes written

public function <CharacterChannel channel> writeCharacters(string content, int startOffset) (int)

Function to write characters

Receiver:

Receiver NameData TypeDescription
channelCharacterChannelThe CharacterChannel to write characters to

Parameters:

Parameter NameData TypeDescription
contentstringText content which should be written
startOffsetintIf the content needs to be written with an offset, the value of that offset

Return Parameters:

Return VariableData TypeDescription
intNumber of characters written

public function <TextRecordChannel channel> writeTextRecord(string[] records)

Function to write text records

Receiver:

Receiver NameData TypeDescription
channelTextRecordChannelThe TextRecordChannel to write text records to

Parameters:

Parameter NameData TypeDescription
recordsstring[]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


Menu

  • Functions
    • <ByteChannel> close()
    • <CharacterChannel> closeCharacterChannel()
    • <TextRecordChannel> closeTextRecordChannel()
    • <ByteChannel> readAllBytes() (blob , int )
    • <CharacterChannel> readAllCharacters() (string )
    • <ByteChannel> readBytes(int numberOfBytes) (blob , int )
    • <CharacterChannel> readCharacters(int numberOfChars) (string )
    • <TextRecordChannel> readTextRecord() (string[] )
    • <ByteChannel> toCharacterChannel(string encoding) (CharacterChannel )
    • <CharacterChannel> toTextRecordChannel(string recordSeparator, string fieldSeparator) (TextRecordChannel )
    • <ByteChannel> writeBytes(blob content, int startOffset) (int )
    • <CharacterChannel> writeCharacters(string content, int startOffset) (int )
    • <TextRecordChannel> writeTextRecord(string[] records)
  • Structs
    • ByteChannel
    • CharacterChannel
    • TextRecordChannel

Copyright 2017 Ballerina API Documentation