Class BufferedOutputStream

All Implemented Interfaces:
AutoCloseable, Seekable, Proxy, AutoCloseable

@Generated("org.javagi.JavaGI") public class BufferedOutputStream extends FilterOutputStream implements 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(), or sized(OutputStream, long) to specify the buffer's size at construction.

To get the size of a buffer within a buffered input stream, use getBufferSize(). To change the size of a buffered output stream's buffer, use setBufferSize(long). Note that the buffer's size cannot be reduced below the size of the data within the buffer.

  • Constructor Details

    • BufferedOutputStream

      public BufferedOutputStream(MemorySegment address)
      Create a BufferedOutputStream instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • BufferedOutputStream

      public BufferedOutputStream(OutputStream baseStream)
      Creates a new buffered output stream for a base stream.
      Parameters:
      baseStream - a OutputStream.
    • BufferedOutputStream

      public BufferedOutputStream()
      Create a new BufferedOutputStream.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the BufferedOutputStream class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected BufferedOutputStream asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class FilterOutputStream
      Returns:
      the instance as if it were its parent type
    • sized

      public static OutputStream sized(OutputStream baseStream, long size)
      Creates a new buffered output stream with a given buffer size.
      Parameters:
      baseStream - a OutputStream.
      size - a gsize.
      Returns:
      a OutputStream with an internal buffer set to size.
    • getAutoGrow

      public boolean getAutoGrow()
      Checks if the buffer automatically grows as data is added.
      Returns:
      TRUE if the stream's buffer automatically grows, FALSE otherwise.
    • getBufferSize

      public long getBufferSize()
      Gets the size of the buffer in the stream.
      Returns:
      the current size of the buffer.
    • setAutoGrow

      public void setAutoGrow(boolean autoGrow)
      Sets whether or not the stream's buffer should automatically grow. If autoGrow 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:
      autoGrow - a gboolean.
    • setBufferSize

      public void setBufferSize(long size)
      Sets the size of the internal buffer to size.
      Parameters:
      size - a gsize.
    • builder

      public static BufferedOutputStream.Builder<? extends BufferedOutputStream.Builder> builder()
      A BufferedOutputStream.Builder object constructs a BufferedOutputStream with the specified properties. Use the various set...() methods to set properties, and finish construction with BufferedOutputStream.Builder.build().
      Returns:
      the builder object