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

Inheritance

%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

Read data of a specified size from a stream

1
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

write

Writes the given data to the stream

1
Stream.write(Buffer data) async;

Call parameters:

  • data : Buffer , given the data to be written

flush

Write file buffer contents to physical device

1
Stream.flush() async;

close

Close the current stream object

1
Stream.close() async;

copyTo

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

toString

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

1
String Stream.toString();

Returns the result:

  • String , returns a string representation of the object

toJSON

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

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

Call parameters:

  • key : String, unused

Returns the result:

  • Value , returns a value containing a JSON serializable