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:
1var reader = new io.BufferedStream(stream);
Inheritance
Constructor
BufferedStream
BufferedStream constructor
1new 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
1readonly Stream BufferedStream.stream;
charset
String, query and set the character set of the current object when processing text, the default is utf-8
1String BufferedStream.charset;
EOL
String, query and set the end of line identifier, by default, posix:\"\n\"; windows:\"\r\n\"
1String BufferedStream.EOL;
fd
Integer, query Stream The corresponding file descriptor value, implemented by the subclass
1readonly Integer BufferedStream.fd;
Member function
readText
Read text with specified characters
1String 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\"
1String 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 group 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\"
1Array 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
2String 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
1BufferedStream.writeText(String txt) async;
Call parameters:
- txt: String, specify the written string
writeLine
Write a string, and write a newline character
1BufferedStream.writeLine(String txt) async;
Call parameters:
- txt: String, specify the written string
read
Read data of the specified size from the stream
1Buffer BufferedStream.read(Integer bytes = -1) async;
Call parameters:
- bytes: Integer, specify the amount of data to be read, the default is to read a random size data block, the size of the data read depends on the device
Return result:
- Buffer, Return the data read from the stream, if there is no data to read, or the connection is interrupted, then return null
write
Write the given data to the stream
1BufferedStream.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
1BufferedStream.flush() async;
close
Close the current stream object
1BufferedStream.close() async;
copyTo
Copy the stream data to the target stream
1
2Long BufferedStream.copyTo(Stream stm,
Long bytes = -1) async;
Call parameters:
- stm: Stream, The 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
1String 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
1Value BufferedStream.toJSON(String key = "");
Call parameters:
- key: String, unused
Return result:
- Value, Returns a value containing JSON serializable