Object built-in object

Object Stream

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

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

inheritance relationship

#lineWidth: 1.5 #font: Helvetica,sans-Serif #fontSize: 10 #leading: 1.6 #.this: fill=lightgray #.class: fill=white [<class>object|toString();toJSON()] [<this>Stream|fd|read();write();flush();close();copyTo()] [<class>BufferedStream] [<class>SeekableStream] [<class>File] [<class>MemoryStream] [<class>RangeStream] [<class>Socket] [<class>SslSocket] [<class>TTYInputStream] [<class>TTYOutputStream] [object] <:- [Stream] [Stream] <:- [BufferedStream] [Stream] <:- [SeekableStream] [SeekableStream] <:- [File] [SeekableStream] <:- [MemoryStream] [SeekableStream] <:- [RangeStream] [Stream] <:- [Socket] [Stream] <:- [SslSocket] [Stream] <:- [TTYInputStream] [Stream] <:- [TTYOutputStream] Stream fd read() write() flush() close() copyTo() object toString() toJSON() BufferedStream SeekableStream File MemoryStream RangeStream Socket SslSocket TTYInputStream TTYOutputStream

Member properties


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

readonly Integer Stream.fd;

member function


Read data of specified size from the stream

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, returns the data read from the stream, or null if there is no data to read or the connection is interrupted


Write the given data to the stream

Stream.write(Buffer data) async;

Call parameters:

  • data:Buffer, given the data to write


Write file buffer contents to physical device

Stream.flush() async;


closes the current stream object

Stream.close() async;


Copy stream data to target stream

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

Call parameters:

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

Return result:

  • Long, returns the number of bytes copied


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

String Stream.toString();

Return result:

  • String, returns the string representation of the object


Returns the JSON format representation of the object, generally returns the set of readable properties defined by the object

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

Call parameters:

  • key: String, unused

Return result:

  • Value, returns a value containing JSON serializable