Skip to content

Gio.BufferedOutputStream

class — extends FilterOutputStream, Seekable

Buffered output stream implements FilterOutputStream and provides for buffered writes.

By default, GBufferedOutputStream's buffer size is set at 4 kilobytes.

To create a buffered output stream, use BufferedOutputStream.new, or BufferedOutputStream.new_sized to specify the buffer's size at construction.

To get the size of a buffer within a buffered input stream, use BufferedOutputStream.get_buffer_size. To change the size of a buffered output stream's buffer, use BufferedOutputStream.set_buffer_size. Note that the buffer's size cannot be reduced below the size of the data within the buffer.

Constructors

new

@classmethod
def new(cls, base_stream: OutputStream) -> OutputStream

Creates a new buffered output stream for a base stream.

Parameters:

new_sized

@classmethod
def new_sized(cls, base_stream: OutputStream, size: int) -> OutputStream

Creates a new buffered output stream with a given buffer size.

Parameters:

Methods

get_auto_grow

def get_auto_grow(self) -> bool

Checks if the buffer automatically grows as data is added.

get_buffer_size

def get_buffer_size(self) -> int

Gets the size of the buffer in the stream.

set_auto_grow

def set_auto_grow(self, auto_grow: bool) -> None

Sets whether or not the stream's buffer should automatically grow. If auto_grow is true, then each write will just make the buffer larger, and you must manually flush the buffer to actually write out the data to the underlying stream.

Parameters:

  • auto_grow — a #gboolean.

set_buffer_size

def set_buffer_size(self, size: int) -> None

Sets the size of the internal buffer to size.

Parameters:

  • size — a #gsize.

Properties

auto_grow

auto_grow: bool  # read/write

Whether the buffer should automatically grow.

buffer_size

buffer_size: int  # read/write

The size of the backend buffer, in bytes.