abstract class std::OutStream
sys::Obj std::OutStream
OutStream is used to write binary and text data to an output stream.
- bigEndian
-
Bool bigEndian()
- charset
-
abstract Charset charset
The current charset used to encode Unicode characters into bytes. The default charset should always be UTF-8.
- close
-
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.
- endian
-
abstract Endian endian
Byte order mode for binary writes. Default is
Endian.big
(network byte order). - flush
-
virtual This flush()
Flush the stream so any buffered bytes are written out. Default implementation does nothing. Throw IOErr on error. Return this.
-
Convenience for
writeChars(obj.toStr)
. If obj is null, then print the string "null". Return this. - printLine
-
virtual This printLine(Obj? obj := "")
Convenience for
writeChars(obj.toStr + "\n")
. If obj is null then print the string "null\n". Return this. - sync
-
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.
- use
-
Void use(Func<Void,OutStream> f)
This OutStream is guaranteed to be closed upon return
- write
-
Write a byte to the output stream. Throw IOErr on error. Return this.
- writeBits
-
This writeBits(Int val, Int num)
Write between 0 and 64 bits of the given integer value. Bits which are only a partial byte are bufferred in RAM until
flush
. - writeBool
-
Write one byte, one if true or zero if false. This method is paired with
InStream.readBool
. Throw IOErr on error. Return this. - writeBuf
-
virtual This writeBuf(Buf buf, Int n := buf.remaining())
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.
- writeBytes
-
virtual This writeBytes(Array<Int8> ba, Int off := 0, Int len := ba.size())
Writes len bytes from the specified byte array starting at offset off to this output stream.
- writeChar
-
virtual This writeChar(Int ch)
Write one or more bytes to the stream for the specified Unicode character based on the current charset encoding. Return this.
- writeChars
-
virtual This writeChars(Str str, Int off := 0, Int len := str.size() - off)
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.
- writeF4
-
Write four bytes as a 32-bit floating point number using configured
endian
order according to Float.bits32. This is paired withInStream.readF4
. Throw IOErr on error. Return this. - writeF8
-
Write eight bytes as a 64-bit floating point number using configured
endian
order according to Float.bits. This is paired withInStream.readF8
. Throw IOErr on error. Return this. - writeI2
-
Write two bytes as a 16-bit number using configured
endian
. This method may be paired withInStream.readU2
orInStream.readS2
. Throw IOErr on error. Return this. - writeI4
-
Write four bytes as a 32-bit number using configured
endian
. This method may be paired withInStream.readU4
orInStream.readS4
. Throw IOErr on error. Return this. - writeI8
-
Write eight bytes as a 64-bit number using configured
endian
. This is paired withInStream.readS8
. Throw IOErr on error. Return this. - writeProps
-
OutStream writeProps(Map<Str,Str> props, Bool close := true)
Write the given map of Str name/value pairs to the output stream according to the Fantom props file format (see
InStream.readProps
for 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. - writeUtf
-
Write a Str in modified UTF-8 format according the
java.io.DataOutput
specification. This method is paired withInStream.readUtf
. Throw IOErr on error. Return this.