OutStream is used to write binary and text data to an output stream.
The current charset used to encode Unicode characters into bytes. The default charset should always be UTF-8.
virtual Bool close()
Close the output stream. This method is guaranteed to never throw an IOErr. Return true if the stream was closed successfully or false if the stream was closed abnormally. Default implementation does nothing and returns true.
Byte order mode for binary writes. Default is
Endian.big(network byte order).
virtual This flush()
Flush the stream so any buffered bytes are written out. Default implementation does nothing. Throw IOErr on error. Return this.
new make(OutStream? out)
Constructor for an OutStream which wraps another stream. All writes to this stream will be routed to the specified inner stream.
writeChars(obj.toStr). If obj is null, then print the string "null". Return this.
writeChars(obj.toStr + "\n"). If obj is null then print the string "null\n". Return this.
virtual This sync()
If this output stream is mapped to a file device, then synchronize all memory buffers to the physical storage device. Throw IOErr on error. Return this.
Write a byte to the output stream. Throw IOErr on error. Return this.
Write between 0 and 64 bits of the given integer value. Bits which are only a partial byte are bufferred in RAM until
Write one byte, one if true or zero if false. This method is paired with
InStream.readBool. Throw IOErr on error. Return this.
Write n bytes from the specified Buf at it's current position to this output stream. If n is defaulted to buf.remaining(), then everything left in the buffer is drained to this output stream. The buf's position is advanced n bytes upon return. Throw IOErr on error. Return this.
Write one or more bytes to the stream for the specified Unicode character based on the current charset encoding. Return this.
Write the Unicode characters in the specified string to the stream using the current charset encoding. Off specifies the index offset to start writing characters and len the number of characters in str to write. Return this.
Write a decimal as a string according to
Write a serialized object from the stream according to the Fantom serialization format. Throw IOErr on error. Return this.
The options may be used to specify the format of the output:
- "indent": Int specifies how many spaces to indent each level. Default is 0.
- "skipDefaults": Bool specifies if we should skip fields at their default values. Field values are compared according to the
equalsmethod. Default is false.
- "skipErrors": Bool specifies if we should skip objects which aren't serializable. If true then we output null and a comment. Default is false.
Write the given map of Str name/value pairs to the output stream according to the Fantom props file format (see
InStream.readPropsfor full specification). The props are written using UTF-8 regardless of this stream's current charset. If close argument is true, then automatically close the stream. Return this.
Write a Str in modified UTF-8 format according the
java.io.DataOutputspecification. This method is paired with
InStream.readUtf. Throw IOErr on error. Return this.
Write a string to this output stream using XML escape sequences. By default only the
< > &characters are escaped. You can use the following flags to escape additional characters:
xmlEscNewlines: escape the
xmlEscQuotes: escape the single and double quote characters
xmlEscUnicode: escape any character greater than 0x7f
Any control character less than 0x20 which is not
\ris always escaped with a numeric reference. Return this.
const static Int xmlEscNewlines := 1
XML escape newline characters. See
const static Int xmlEscQuotes := 2
XML escape single and double quotes. See
const static Int xmlEscUnicode := 4
XML escape any character greater then 0x7f. See