objectMemoryStream
memory stream object
The MemoryStream object creates a memory-based stream object, the creation method:
1var ms = new io.MemoryStream();
inheritance relationship
Constructor
MemoryStream
MemoryStream constructor
1new MemoryStream();
Member properties
fd
Integer, queryStreamThe corresponding file descriptor value, implemented by subclasses
1readonly Integer MemoryStream.fd;
member function
setTime
Force the last update time of the memory stream object
1MemoryStream.setTime(Date d);
Call parameters:
- d: Date, specify the time to set
clone
Create a read-only copy of the current memory stream
1MemoryStream MemoryStream.clone();
Return result:
- MemoryStream, returns a read-only memory stream object
clear
Clear memory file data, reset pointer
1MemoryStream.clear();
seek
Move the current operation position of the file
1
2MemoryStream.seek(Long offset,
Integer whence = fs.SEEK_SET);
Call parameters:
- offset: Long, specifies the new position
- whence: Integer, specifies the position reference, the allowed values are: SEEK_SET, SEEK_CUR, SEEK_END
tell
query stream current position
1Long MemoryStream.tell();
Return result:
- Long, returns the current position of the stream
rewind
Move the current position to the beginning of the stream
1MemoryStream.rewind();
size
query stream size
1Long MemoryStream.size();
Return result:
- Long, returns the stream size
readAll
Read all remaining data from the stream
1Buffer MemoryStream.readAll() async;
Return result:
- Buffer, returns the data read from the stream, or null if there is no data to read or the connection is interrupted
truncate
Modify the file size, if the new size is smaller than the original size, the file is truncated
1MemoryStream.truncate(Long bytes) async;
Call parameters:
- bytes: Long, the new file size
eof
Check if the file is at the end
1Boolean MemoryStream.eof();
Return result:
- Boolean, return True to indicate the end
stat
Query the basic information of the current file
1Stat MemoryStream.stat() async;
Return result:
read
Read data of specified size from the stream
1Buffer MemoryStream.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
Write the given data to the stream
1MemoryStream.write(Buffer data) async;
Call parameters:
- data:Buffer, given the data to write
flush
Write file buffer contents to physical device
1MemoryStream.flush() async;
close
closes the current stream object
1MemoryStream.close() async;
copyTo
Copy stream data to target stream
1
2Long MemoryStream.copyTo(Stream stm,
Long bytes = -1) async;
Call parameters:
- stm:Stream, the target stream object
- bytes: Long, 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 reimplemented according to its own characteristics
1String MemoryStream.toString();
Return result:
- String, returns the string representation of the object
toJSON
Returns the JSON format representation of the object, generally returns the set of readable properties defined by the object
1Value MemoryStream.toJSON(String key = "");
Call parameters:
- key: String, unused
Return result:
- Value, returns a value containing JSON serializable