Object built-in object

Object BufferedStream

Cache read object

The BufferedReader object is used to cache binary stream object data and provide text reading capabilities. It only supports utf-8 format conversion. Creation method:

1
var reader = new io.BufferedStream(stream);

Inheritance

Constructor

BufferedStream

BufferedStream constructor

1
new BufferedStream(Stream stm);

Call parameters:

  • stm : Stream , the binary base stream object of BufferedStream

Member attributes

stream

Stream , query the stream object when the cache object is created

1
readonly Stream BufferedStream.stream;

charset

String, query and set the character set when the current object processes text, the default is utf-8

1
String BufferedStream.charset;

EOL

String, query and set the end of line identifier, by default, posix:\"\n\"; windows:\"\r\n\"

1
String BufferedStream.EOL;

Member function

readText

Read text with specified characters

1
String BufferedStream.readText(Integer size) async;

Call parameters:

  • size : Integer, specify the number of text characters to be read, subject to utf8 or the specified number of encoded bytes

Return result:

  • String , returns the read text string, if there is no data to read, or the connection is interrupted, it returns null

readLine

Read a line of text, the end of the line is based on the setting of the EOL attribute, by default, posix:\"\n\"; windows:\"\r\n\"

1
String BufferedStream.readLine(Integer maxlen = -1) async;

Call parameters:

  • maxlen : Integer, specify the maximum character string read this time, subject to the number of utf8 encoded bytes, the number of characters is not limited by default

Return result:

  • String , returns the read text string, if there is no data to read, or the connection is interrupted, it returns null

readLines

Read a set of text lines in an array. The end of the line is identified based on the setting of the EOL attribute. By default, posix:\"\n\"; windows:\"\r\n\"

1
Array BufferedStream.readLines(Integer maxlines = -1);

Call parameters:

  • maxlines : Integer, specify the maximum number of lines read this time, read all text lines by default

Return result:

  • Array , returns the read text line array, if there is no data to read, or the connection is interrupted, empty array

readUntil

Read a text string, ending with the specified byte

1 2
String BufferedStream.readUntil(String mk, Integer maxlen = -1) async;

Call parameters:

  • mk : String, specify the ending string
  • maxlen : Integer, specify the maximum character string read this time, subject to the number of utf8 encoded bytes, the number of characters is not limited by default

Return result:

  • String , returns the read text string, if there is no data to read, or the connection is interrupted, it returns null

writeText

Write a string

1
BufferedStream.writeText(String txt) async;

Call parameters:

  • txt : String, specify the written string

writeLine

Write a string and write a newline character

1
BufferedStream.writeLine(String txt) async;

Call parameters:

  • txt : String, specify the written string

read

Read data of the specified size from the stream

1
Buffer BufferedStream.read(Integer bytes = -1) async;

Call parameters:

  • bytes : Integer, specify the amount of data to be read, the default is to read data blocks of random size, the size of the data read depends on the device

Return result:

  • Buffer , returns the data read from the stream, if there is no data to read, or the connection is interrupted, it returns null

write

Write the given data to the stream

1
BufferedStream.write(Buffer data) async;

Call parameters:

  • data : Buffer , given the data to be written

flush

Write the contents of the file buffer to the physical device

1
BufferedStream.flush() async;

close

Close the current stream object

1
BufferedStream.close() async;

copyTo

Copy stream data to the target stream

1 2
Long BufferedStream.copyTo(Stream stm, Long bytes = -1) async;

Call parameters:

  • stm : Stream , target stream object
  • bytes : Long, the number of bytes copied

Return result:

  • Long , returns the number of bytes copied

toString

Returns the string representation of the object, generally returns "[Native Object]", the object can be re-implemented according to its own characteristics

1
String BufferedStream.toString();

Return result:

  • String , returns the string representation of the object

toJSON

Returns the JSON format representation of the object, generally returns a collection of readable attributes defined by the object

1
Value BufferedStream.toJSON(String key = "");

Call parameters:

  • key : String, unused

Return result:

  • Value , returns a value containing JSON serializable