Object built-in object

Object Stream

Stream operation object for reading and writing binary data streams

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


%0 object object toString() toJSON() Stream Stream 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

Member function


Read data of a specified size from a stream

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

Call parameters:

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

Returns the result:

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


Writes the given data to the stream

Stream.write(Buffer data) async;

Call parameters:

  • data : Buffer , given the data to be written


Write file buffer contents to physical device

Stream.flush() async;


Close the current stream object

Stream.close() async;


Copy stream data to destination stream

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

Call parameters:

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

Returns the result:

  • Long , returns the number of bytes copied


Returns a string representation of the object, usually "[Native Object]". Objects can be reimplemented according to their own characteristics

String Stream.toString();

Returns the result:

  • String , returns a string representation of the object


Returns a JSON representation of the object, typically returning a collection of readable properties defined by the object

Value Stream.toJSON(String key = "");

Call parameters:

  • key : String, unused

Returns the result:

  • Value , returns a value containing a JSON serializable