Skip to content
FutureBlitz

    Install

    Import std.io.buffered

    BufferedWriter

    std.io.buffered

    class

    Public Class BufferedWriter Implements Writer

    Writes another Writer a buffer's bytes at a time: what's written waits in a buffer until a write doesn't fit what's left of it, or Flush sends it on. What's still waiting when it goes is written then, without the errors that Flush would give.

    Examples

    Local memory = MemoryStream()
    Local writer = BufferedWriter(memory, 64)
    Try writer.WriteText("held ")
    Try writer.WriteText("back")
    Expect(memory.Count == 0)
    Try writer.Flush()
    Expect(String.FromUtf8(memory.ToArray()) == "held back")

    std/io/buffered.fb, line 163

    • @PanicsAtCaller Public New(inner: Writer, size: Int64 = 4096) constructor #

      Writes inner size bytes at a time. Panics when size is below 1.

    • Public Method Write(from: Buffer<UInt8>) Throws IOError method #

      Keeps the bytes, sending on what waits first when they don't fit what's left of the buffer. A write of a whole buffer or more goes straight to the other Writer, after what waits.

    • Public Async Method WriteAsync(from: Buffer<UInt8>) Throws IOError method #

      Write's Async twin, which sends on what waits by the other Writer's WriteAsync when the bytes don't fit.

    • Public Method Flush() Throws IOError method #

      Sends on what waits, and flushes the other Writer.

    • Public Async Method FlushAsync() Throws IOError method #

      Flush's Async twin: sends on what waits, and flushes the other Writer, while the main thread goes on.

    Report an issue with this page or with FutureBlitz on GitHub.