flush

flush(stream)

Commit all currently buffered writes to the given stream.

Examples

julia> io = open("output.txt", "w")
IOStream(<file output.txt>)

julia> println(io, "Hello, World!")

julia> flush(io)

This example demonstrates the use of flush to commit all buffered writes to the specified stream. The println function writes the string "Hello, World!" to the io stream. The flush function ensures that the write operation is immediately committed to the stream.

Common mistake example:

julia> io = open("output.txt", "r")
IOStream(<file output.txt>)

julia> flush(io)
ERROR: MethodError: no method matching flush(::IOStream)

In this example, an error occurs because the flush function is called on a read-only stream ("r" mode). The flush function can only be used on writable streams. Make sure to open the stream in a writable mode before using flush.

See Also

deserialize, eachline, eof, fd, flush, IOBuffer, ismarked, isopen, isreadonly, mark, nb_available, open, pipeline, position, read, read!, readavailable, readbytes, readbytes!, readline, redirect_stderr, redirect_stdin, reset, seek, seekend, seekstart, serialize, skip, skipchars, TextDisplay, unmark, write, writemime,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: