[ Stream I/O | Reference Manual | Alphabetic Index ]

flush(+Stream)

Flushes the output stream Stream.
Stream
Stream handle or alias (atom)

Description

Used to flush any data contained in the Stream buffer of an output stream. Flushing means that the data is transferred from a memory buffer to the operation system's I/O system.

Buffers are normally only flushed when they get full, or when the stream is closed. Explicit flushing in between reduces performance, but sometimes it is desirable to make sure that data is actually written at certain points.

Note that streams can be also be configured to flush automatically at every newline, using the flush(end_of_line) option.

Stream can be a symbolic stream name (atom) or a stream handle.

Modes and Determinism

Exceptions

(4) instantiation fault
Stream is not instantiated.
(5) type error
Stream is instantiated neither to a stream handle nor an atom.
(192) illegal stream mode
Stream is not an output stream.

Examples

Success:
      flush(output).
      flush(null).


Error:
      flush(Stream).            (Error 4).
      flush("Stream").          (Error 5).
      flush(12).                (Error 192). % no such stream
      flush(debug_input).       (Error 192). % input stream

See Also

set_stream_property / 3, open / 3, open / 4, close / 1, tyo / 2