Class FileOutputStream

All Implemented Interfaces:
PointerInterface

public class FileOutputStream extends OutputStream
GFileOutputStream provides output streams that write their
content to a file.

GFileOutputStream implements #GSeekable, which allows the output
stream to jump to arbitrary positions in the file and to truncate
the file, provided the filesystem of the file supports these
operations.

To find the position of a file output stream, use g_seekable_tell().
To find out if a file output stream supports seeking, use
g_seekable_can_seek().To position a file output stream, use
g_seekable_seek(). To find out if a file output stream supports
truncating, use g_seekable_can_truncate(). To truncate a file output
stream, use g_seekable_truncate().

https://docs.gtk.org/gio/class.FileOutputStream.html

  • Constructor Details

  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getEtag

      public Str getEtag()
      Gets the entity tag for the file when it has been written.
      This must be called after the stream has been written
      and closed, as the etag can change while writing.
      Returns:
      the entity tag for the stream.
    • queryInfo

      public FileInfo queryInfo(@Nonnull Str attributes, @Nullable Cancellable cancellable) throws AllocationError
      Queries a file output stream for the given @attributes.
      This function blocks while querying the stream. For the asynchronous
      version of this function, see g_file_output_stream_query_info_async().
      While the stream is blocked, the stream will set the pending flag
      internally, and any other operations on the stream will fail with
      %G_IO_ERROR_PENDING.

      Can fail if the stream was already closed (with @error being set to
      %G_IO_ERROR_CLOSED), the stream has pending operations (with @error being
      set to %G_IO_ERROR_PENDING), or if querying info is not supported for
      the stream's interface (with @error being set to %G_IO_ERROR_NOT_SUPPORTED). In
      all cases of failure, %NULL will be returned.

      If @cancellable is not %NULL, then the operation can be cancelled by
      triggering the cancellable object from another thread. If the operation
      was cancelled, the error %G_IO_ERROR_CANCELLED will be set, and %NULL will
      be returned.
      Parameters:
      attributes - a file attribute query string.
      cancellable - optional #GCancellable object, %NULL to ignore.
      Returns:
      a #GFileInfo for the @stream, or %NULL on error.
      Throws:
      AllocationError
    • queryInfo

      public FileInfo queryInfo(String attributes, @Nullable Cancellable cancellable) throws AllocationError
      Queries a file output stream for the given @attributes.
      This function blocks while querying the stream. For the asynchronous
      version of this function, see g_file_output_stream_query_info_async().
      While the stream is blocked, the stream will set the pending flag
      internally, and any other operations on the stream will fail with
      %G_IO_ERROR_PENDING.

      Can fail if the stream was already closed (with @error being set to
      %G_IO_ERROR_CLOSED), the stream has pending operations (with @error being
      set to %G_IO_ERROR_PENDING), or if querying info is not supported for
      the stream's interface (with @error being set to %G_IO_ERROR_NOT_SUPPORTED). In
      all cases of failure, %NULL will be returned.

      If @cancellable is not %NULL, then the operation can be cancelled by
      triggering the cancellable object from another thread. If the operation
      was cancelled, the error %G_IO_ERROR_CANCELLED will be set, and %NULL will
      be returned.
      Parameters:
      attributes - a file attribute query string.
      cancellable - optional #GCancellable object, %NULL to ignore.
      Returns:
      a #GFileInfo for the @stream, or %NULL on error.
      Throws:
      AllocationError
    • queryInfoAsync

      public void queryInfoAsync(@Nonnull Str attributes, int io_priority, @Nullable Cancellable cancellable, FileOutputStream.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Asynchronously queries the @stream for a #GFileInfo. When completed,
      @callback will be called with a #GAsyncResult which can be used to
      finish the operation with g_file_output_stream_query_info_finish().

      For the synchronous version of this function, see
      g_file_output_stream_query_info().
      Parameters:
      attributes - a file attribute query string.
      io_priority - the [I/O priority][gio-GIOScheduler] of the request
      cancellable - optional #GCancellable object, %NULL to ignore.
      callback - callback to call when the request is satisfied
      user_data - the data to pass to callback function
    • queryInfoAsync

      public void queryInfoAsync(String attributes, int io_priority, @Nullable Cancellable cancellable, FileOutputStream.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Asynchronously queries the @stream for a #GFileInfo. When completed,
      @callback will be called with a #GAsyncResult which can be used to
      finish the operation with g_file_output_stream_query_info_finish().

      For the synchronous version of this function, see
      g_file_output_stream_query_info().
      Parameters:
      attributes - a file attribute query string.
      io_priority - the [I/O priority][gio-GIOScheduler] of the request
      cancellable - optional #GCancellable object, %NULL to ignore.
      callback - callback to call when the request is satisfied
      user_data - the data to pass to callback function
    • queryInfoFinish

      public FileInfo queryInfoFinish(@Nonnull AsyncResult result) throws AllocationError
      Finalizes the asynchronous query started
      by g_file_output_stream_query_info_async().
      Parameters:
      result - a #GAsyncResult.
      Returns:
      A #GFileInfo for the finished query.
      Throws:
      AllocationError
    • asSeekable

      public Seekable asSeekable()
      Implements interface Seekable. Call this to get access to interface functions.
      Returns:
      Seekable
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()