Class MemoryInputStream

All Implemented Interfaces:
AutoCloseable, PollableInputStream, Seekable, Proxy, AutoCloseable

@Generated("org.javagi.JavaGI") public class MemoryInputStream extends InputStream implements PollableInputStream, Seekable

GMemoryInputStream is a class for using arbitrary memory chunks as input for GIO streaming input operations.

As of GLib 2.34, GMemoryInputStream implements PollableInputStream.

  • Constructor Details

    • MemoryInputStream

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

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

    • getType

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

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

      protected MemoryInputStream 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 InputStream
      Returns:
      the instance as if it were its parent type
    • fromBytes

      public static InputStream fromBytes(byte[] bytes)
      Creates a new GMemoryInputStream with data from the given bytes.
      Parameters:
      bytes - a GBytes
      Returns:
      new GInputStream read from bytes
      Since:
      2.34
    • fromData

      public static InputStream fromData(@Nullable byte @Nullable [] data)
      Creates a new GMemoryInputStream with data in memory of a given size.
      Parameters:
      data - input data
      Returns:
      new GInputStream read from data of len bytes.
    • addBytes

      public void addBytes(byte[] bytes)
      Appends bytes to data that can be read from the input stream.
      Parameters:
      bytes - input data
      Since:
      2.34
    • addData

      public void addData(@Nullable byte @Nullable [] data)
      Appends data to data that can be read from the input stream
      Parameters:
      data - input data
    • builder

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