mixin io.Stream
Description
Base stream beahviour that is shared between files, sockets and other stream-like objects
Instance properties
-
autoFlush #
io.Stream#autoFlush -> BoolShould
io.Stream#flushbe called every every write. Default false. -
fieldSeparator #
io.Stream#fieldSeparator -> StringWritten between each argument passed to
io.Stream#print. Default" ". -
recordSeparator #
io.Stream#recordSeparator -> StringWritten once after each call to print. Default
"\n"(new line). Set tonullorundefinedto disable.
Instance methods
-
flush #
io.Stream#flush() ⇒ undefinedTell the underlying OS to flush the file cache to disk.
-
print #
io.Stream#print(args...) ⇒ undefined-
args(String|Array) – What to print
Print args to the stream, seperated by
io.Stream#fieldSeparatorand terminated with aio.Stream#recordSeparator.If any of the arguments is an Array, it is expaneded out. That is to say, the following two lines would print the same thing:
stream.print(1, [2, 3], 4) stream.print(1, 2, 3, 4) -
-
read #
io.Stream#read([size = 4096]) ⇒ String-
size(Integer) – number of bytes to read
Read a chunk of text. The
sizeparam is the number of bytes to read currently, and not number of characters as it should be. -
-
readBinary #
io.Stream#readBinary(size, read_into) ⇒ binary- size (Integer): number of bytes to read
- read_into (binary.ByteArray): append data into this blob
Read a chunk of data. Behaves similarly to #readWholebinary, just reads only the next
sizebytes, not everything. -
readLine #
io.Stream#readLine([sep]) ⇒ String-
sep(String) – line seperator.
Read a line of text. A line is defined as everything up until EOF or until
sepis sene. Currently the separator must be a single character and must be in the range [0,127]. -
-
readWhole #
io.Stream#readWhole() ⇒ StringRead the rest of the stream as a text
-
readWholeBinary #
io.Stream#readWholeBinary() ⇒ binary.ByteString
io.Stream#readWholeBinary(read_into) ⇒ read_into- read_into (binary.ByteArray): Append file contents into this blob
Read the rest of the stream as binary data.
If
read_intois passed, the read data will be appended to it, and the same ByteArray will be returned. Otherwise a new ByteString is returned. -
write #
io.Stream#write(data) ⇒ undefined- data (Any): What to print