Object built-in object

Object Stream

Stream operation object, used for reading and writing of binary data stream

Stream is the basic object, used to define standard excuses for stream processing, and cannot be created independently

Inheritance relationship

%0 object object toString() toJSON() Stream Stream fd read() write() flush() close() copyTo() object->Stream BufferedStream BufferedStream Stream->BufferedStream SeekableStream SeekableStream Stream->SeekableStream Socket Socket Stream->Socket SslSocket SslSocket Stream->SslSocket File File SeekableStream->File MemoryStream MemoryStream SeekableStream->MemoryStream RangeStream RangeStream SeekableStream->RangeStream

Member attributes

fd

Integer, query the file descriptor value corresponding to the Stream, implemented by the subclass

1
readonly Integer Stream.fd;

Member function

read

Read data of the specified size from the stream

1
Buffer Stream.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

1
Stream.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
Stream.flush() async;

close

Close the current stream object

1
Stream.close() async;

copyTo

Copy the stream data to the target stream

1 2
Long Stream.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 Stream.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 Stream.toJSON(String key = "");

Call parameters:

  • key: String, unused

Return result:

  • Value, Returns a value containing JSON serializable