Klasse DataInputStream

Alle implementierten Schnittstellen:
PointerInterface

public class DataInputStream extends BufferedInputStream
Data input stream implements [class@Gio.InputStream] and includes functions
for reading structured data directly from a binary input stream.

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

  • Konstruktordetails

    • DataInputStream

      public DataInputStream(PointerContainer pointer)
    • DataInputStream

      public DataInputStream(@Nonnull InputStream base_stream)
      Creates a new data input stream for the @base_stream.
      Parameter:
      base_stream - a #GInputStream.
  • Methodendetails

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getByteOrder

      public int getByteOrder()
      Gets the byte order for the data input stream.
      Gibt zurück:
      the @stream's current #GDataStreamByteOrder.
    • getNewlineType

      public int getNewlineType()
      Gets the current newline type for the @stream.
      Gibt zurück:
      #GDataStreamNewlineType for the given @stream.
    • readInt16

      public int readInt16(@Nullable Cancellable cancellable) throws AllocationError
      Reads a 16-bit/2-byte value from @stream.

      In order to get the correct byte order for this read operation,
      see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().
      Parameter:
      cancellable - optional #GCancellable object, %NULL to ignore.
      Gibt zurück:
      a signed 16-bit/2-byte value read from @stream or `0` if an error occurred.
      Löst aus:
      AllocationError
    • readInt32

      public int readInt32(@Nullable Cancellable cancellable) throws AllocationError
      Reads a signed 32-bit/4-byte value from @stream.

      In order to get the correct byte order for this read operation,
      see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().

      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 returned.
      Parameter:
      cancellable - optional #GCancellable object, %NULL to ignore.
      Gibt zurück:
      a signed 32-bit/4-byte value read from the @stream or `0` if an error occurred.
      Löst aus:
      AllocationError
    • readInt64

      public long readInt64(@Nullable Cancellable cancellable) throws AllocationError
      Reads a 64-bit/8-byte value from @stream.

      In order to get the correct byte order for this read operation,
      see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().

      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 returned.
      Parameter:
      cancellable - optional #GCancellable object, %NULL to ignore.
      Gibt zurück:
      a signed 64-bit/8-byte value read from @stream or `0` if an error occurred.
      Löst aus:
      AllocationError
    • readLine

      public Str readLine(@Nullable Int64 length, @Nullable Cancellable cancellable) throws AllocationError
      Reads a line from the data input stream. Note that no encoding
      checks or conversion is performed; the input is not guaranteed to
      be UTF-8, and may in fact have embedded NUL characters.

      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 returned.
      Parameter:
      length - a #gsize to get the length of the data read in.
      cancellable - optional #GCancellable object, %NULL to ignore.
      Gibt zurück:
      a NUL terminated byte array with the line that was read in (without the newlines). Set @length to a #gsize to get the length of the read line. On an error, it will return %NULL and @error will be set. If there's no content to read, it will still return %NULL, but @error won't be set.
      Löst aus:
      AllocationError
    • readLineAsync

      public void readLineAsync(int io_priority, @Nullable Cancellable cancellable, DataInputStream.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      The asynchronous version of g_data_input_stream_read_line(). It is
      an error to have two outstanding calls to this function.

      When the operation is finished, @callback will be called. You
      can then call g_data_input_stream_read_line_finish() to get
      the result of the operation.
      Parameter:
      io_priority - the [I/O priority](iface.AsyncResult.html#io-priority) 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.
    • readLineFinish

      public Str readLineFinish(@Nonnull AsyncResult result, @Nullable Int64 length) throws AllocationError
      Finish an asynchronous call started by
      g_data_input_stream_read_line_async(). Note the warning about
      string encoding in g_data_input_stream_read_line() applies here as
      well.
      Parameter:
      result - the #GAsyncResult that was provided to the callback.
      length - a #gsize to get the length of the data read in.
      Gibt zurück:
      a NUL-terminated byte array with the line that was read in (without the newlines). Set @length to a #gsize to get the length of the read line. On an error, it will return %NULL and @error will be set. If there's no content to read, it will still return %NULL, but @error won't be set.
      Löst aus:
      AllocationError
    • readLineFinishUtf8

      public Str readLineFinishUtf8(@Nonnull AsyncResult result, @Nullable Int64 length) throws AllocationError
      Finish an asynchronous call started by
      g_data_input_stream_read_line_async().
      Parameter:
      result - the #GAsyncResult that was provided to the callback.
      length - a #gsize to get the length of the data read in.
      Gibt zurück:
      a string with the line that was read in (without the newlines). Set @length to a #gsize to get the length of the read line. On an error, it will return %NULL and @error will be set. For UTF-8 conversion errors, the set error domain is %G_CONVERT_ERROR. If there's no content to read, it will still return %NULL, but @error won't be set.
      Löst aus:
      AllocationError
    • readLineUtf8

      public Str readLineUtf8(@Nullable Int64 length, @Nullable Cancellable cancellable) throws AllocationError
      Reads a UTF-8 encoded line from the data input stream.

      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 returned.
      Parameter:
      length - a #gsize to get the length of the data read in.
      cancellable - optional #GCancellable object, %NULL to ignore.
      Gibt zurück:
      a NUL terminated UTF-8 string with the line that was read in (without the newlines). Set @length to a #gsize to get the length of the read line. On an error, it will return %NULL and @error will be set. For UTF-8 conversion errors, the set error domain is %G_CONVERT_ERROR. If there's no content to read, it will still return %NULL, but @error won't be set.
      Löst aus:
      AllocationError
    • readUint16

      public int readUint16(@Nullable Cancellable cancellable) throws AllocationError
      Reads an unsigned 16-bit/2-byte value from @stream.

      In order to get the correct byte order for this read operation,
      see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().
      Parameter:
      cancellable - optional #GCancellable object, %NULL to ignore.
      Gibt zurück:
      an unsigned 16-bit/2-byte value read from the @stream or `0` if an error occurred.
      Löst aus:
      AllocationError
    • readUint32

      public int readUint32(@Nullable Cancellable cancellable) throws AllocationError
      Reads an unsigned 32-bit/4-byte value from @stream.

      In order to get the correct byte order for this read operation,
      see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().

      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 returned.
      Parameter:
      cancellable - optional #GCancellable object, %NULL to ignore.
      Gibt zurück:
      an unsigned 32-bit/4-byte value read from the @stream or `0` if an error occurred.
      Löst aus:
      AllocationError
    • readUint64

      public long readUint64(@Nullable Cancellable cancellable) throws AllocationError
      Reads an unsigned 64-bit/8-byte value from @stream.

      In order to get the correct byte order for this read operation,
      see g_data_input_stream_get_byte_order().

      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 returned.
      Parameter:
      cancellable - optional #GCancellable object, %NULL to ignore.
      Gibt zurück:
      an unsigned 64-bit/8-byte read from @stream or `0` if an error occurred.
      Löst aus:
      AllocationError
    • readUntil

      @Deprecated public Str readUntil(@Nonnull Str stop_chars, @Nullable Int64 length, @Nullable Cancellable cancellable) throws AllocationError
      Veraltet.
      Reads a string from the data input stream, up to the first
      occurrence of any of the stop characters.

      Note that, in contrast to g_data_input_stream_read_until_async(),
      this function consumes the stop character that it finds.

      Don't use this function in new code. Its functionality is
      inconsistent with g_data_input_stream_read_until_async(). Both
      functions will be marked as deprecated in a future release. Use
      g_data_input_stream_read_upto() instead, but note that that function
      does not consume the stop character.
      Parameter:
      stop_chars - characters to terminate the read.
      length - a #gsize to get the length of the data read in.
      cancellable - optional #GCancellable object, %NULL to ignore.
      Gibt zurück:
      a string with the data that was read before encountering any of the stop characters. Set @length to a #gsize to get the length of the string. This function will return %NULL on an error.
      Löst aus:
      AllocationError
    • readUntil

      @Deprecated public Str readUntil(String stop_chars, @Nullable Int64 length, @Nullable Cancellable cancellable) throws AllocationError
      Veraltet.
      Reads a string from the data input stream, up to the first
      occurrence of any of the stop characters.

      Note that, in contrast to g_data_input_stream_read_until_async(),
      this function consumes the stop character that it finds.

      Don't use this function in new code. Its functionality is
      inconsistent with g_data_input_stream_read_until_async(). Both
      functions will be marked as deprecated in a future release. Use
      g_data_input_stream_read_upto() instead, but note that that function
      does not consume the stop character.
      Parameter:
      stop_chars - characters to terminate the read.
      length - a #gsize to get the length of the data read in.
      cancellable - optional #GCancellable object, %NULL to ignore.
      Gibt zurück:
      a string with the data that was read before encountering any of the stop characters. Set @length to a #gsize to get the length of the string. This function will return %NULL on an error.
      Löst aus:
      AllocationError
    • readUntilAsync

      @Deprecated public void readUntilAsync(@Nonnull Str stop_chars, int io_priority, @Nullable Cancellable cancellable, DataInputStream.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Veraltet.
      The asynchronous version of g_data_input_stream_read_until().
      It is an error to have two outstanding calls to this function.

      Note that, in contrast to g_data_input_stream_read_until(),
      this function does not consume the stop character that it finds. You
      must read it for yourself.

      When the operation is finished, @callback will be called. You
      can then call g_data_input_stream_read_until_finish() to get
      the result of the operation.

      Don't use this function in new code. Its functionality is
      inconsistent with g_data_input_stream_read_until(). Both functions
      will be marked as deprecated in a future release. Use
      g_data_input_stream_read_upto_async() instead.
      Parameter:
      stop_chars - characters to terminate the read.
      io_priority - the [I/O priority](iface.AsyncResult.html#io-priority) 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.
    • readUntilAsync

      @Deprecated public void readUntilAsync(String stop_chars, int io_priority, @Nullable Cancellable cancellable, DataInputStream.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      Veraltet.
      The asynchronous version of g_data_input_stream_read_until().
      It is an error to have two outstanding calls to this function.

      Note that, in contrast to g_data_input_stream_read_until(),
      this function does not consume the stop character that it finds. You
      must read it for yourself.

      When the operation is finished, @callback will be called. You
      can then call g_data_input_stream_read_until_finish() to get
      the result of the operation.

      Don't use this function in new code. Its functionality is
      inconsistent with g_data_input_stream_read_until(). Both functions
      will be marked as deprecated in a future release. Use
      g_data_input_stream_read_upto_async() instead.
      Parameter:
      stop_chars - characters to terminate the read.
      io_priority - the [I/O priority](iface.AsyncResult.html#io-priority) 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.
    • readUntilFinish

      @Deprecated public Str readUntilFinish(@Nonnull AsyncResult result, @Nullable Int64 length) throws AllocationError
      Veraltet.
      Finish an asynchronous call started by
      g_data_input_stream_read_until_async().
      Parameter:
      result - the #GAsyncResult that was provided to the callback.
      length - a #gsize to get the length of the data read in.
      Gibt zurück:
      a string with the data that was read before encountering any of the stop characters. Set @length to a #gsize to get the length of the string. This function will return %NULL on an error.
      Löst aus:
      AllocationError
    • readUpto

      public Str readUpto(@Nonnull Str stop_chars, long stop_chars_len, @Nullable Int64 length, @Nullable Cancellable cancellable) throws AllocationError
      Reads a string from the data input stream, up to the first
      occurrence of any of the stop characters.

      In contrast to g_data_input_stream_read_until(), this function
      does not consume the stop character. You have to use
      g_data_input_stream_read_byte() to get it before calling
      g_data_input_stream_read_upto() again.

      Note that @stop_chars may contain '\0' if @stop_chars_len is
      specified.

      The returned string will always be nul-terminated on success.
      Parameter:
      stop_chars - characters to terminate the read
      stop_chars_len - length of @stop_chars. May be -1 if @stop_chars is nul-terminated
      length - a #gsize to get the length of the data read in
      cancellable - optional #GCancellable object, %NULL to ignore
      Gibt zurück:
      a string with the data that was read before encountering any of the stop characters. Set @length to a #gsize to get the length of the string. This function will return %NULL on an error
      Löst aus:
      AllocationError
    • readUpto

      public Str readUpto(String stop_chars, long stop_chars_len, @Nullable Int64 length, @Nullable Cancellable cancellable) throws AllocationError
      Reads a string from the data input stream, up to the first
      occurrence of any of the stop characters.

      In contrast to g_data_input_stream_read_until(), this function
      does not consume the stop character. You have to use
      g_data_input_stream_read_byte() to get it before calling
      g_data_input_stream_read_upto() again.

      Note that @stop_chars may contain '\0' if @stop_chars_len is
      specified.

      The returned string will always be nul-terminated on success.
      Parameter:
      stop_chars - characters to terminate the read
      stop_chars_len - length of @stop_chars. May be -1 if @stop_chars is nul-terminated
      length - a #gsize to get the length of the data read in
      cancellable - optional #GCancellable object, %NULL to ignore
      Gibt zurück:
      a string with the data that was read before encountering any of the stop characters. Set @length to a #gsize to get the length of the string. This function will return %NULL on an error
      Löst aus:
      AllocationError
    • readUptoAsync

      public void readUptoAsync(@Nonnull Str stop_chars, long stop_chars_len, int io_priority, @Nullable Cancellable cancellable, DataInputStream.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      The asynchronous version of g_data_input_stream_read_upto().
      It is an error to have two outstanding calls to this function.

      In contrast to g_data_input_stream_read_until(), this function
      does not consume the stop character. You have to use
      g_data_input_stream_read_byte() to get it before calling
      g_data_input_stream_read_upto() again.

      Note that @stop_chars may contain '\0' if @stop_chars_len is
      specified.

      When the operation is finished, @callback will be called. You
      can then call g_data_input_stream_read_upto_finish() to get
      the result of the operation.
      Parameter:
      stop_chars - characters to terminate the read
      stop_chars_len - length of @stop_chars. May be -1 if @stop_chars is nul-terminated
      io_priority - the [I/O priority](iface.AsyncResult.html#io-priority) 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
    • readUptoAsync

      public void readUptoAsync(String stop_chars, long stop_chars_len, int io_priority, @Nullable Cancellable cancellable, DataInputStream.OnAsyncReadyCallback callback, @Nullable Pointer user_data)
      The asynchronous version of g_data_input_stream_read_upto().
      It is an error to have two outstanding calls to this function.

      In contrast to g_data_input_stream_read_until(), this function
      does not consume the stop character. You have to use
      g_data_input_stream_read_byte() to get it before calling
      g_data_input_stream_read_upto() again.

      Note that @stop_chars may contain '\0' if @stop_chars_len is
      specified.

      When the operation is finished, @callback will be called. You
      can then call g_data_input_stream_read_upto_finish() to get
      the result of the operation.
      Parameter:
      stop_chars - characters to terminate the read
      stop_chars_len - length of @stop_chars. May be -1 if @stop_chars is nul-terminated
      io_priority - the [I/O priority](iface.AsyncResult.html#io-priority) 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
    • readUptoFinish

      public Str readUptoFinish(@Nonnull AsyncResult result, @Nullable Int64 length) throws AllocationError
      Finish an asynchronous call started by
      g_data_input_stream_read_upto_async().

      Note that this function does not consume the stop character. You
      have to use g_data_input_stream_read_byte() to get it before calling
      g_data_input_stream_read_upto_async() again.

      The returned string will always be nul-terminated on success.
      Parameter:
      result - the #GAsyncResult that was provided to the callback
      length - a #gsize to get the length of the data read in
      Gibt zurück:
      a string with the data that was read before encountering any of the stop characters. Set @length to a #gsize to get the length of the string. This function will return %NULL on an error.
      Löst aus:
      AllocationError
    • setByteOrder

      public void setByteOrder(int order)
      This function sets the byte order for the given @stream. All subsequent
      reads from the @stream will be read in the given @order.
      Parameter:
      order - a #GDataStreamByteOrder to set.
    • setNewlineType

      public void setNewlineType(int type)
      Sets the newline type for the @stream.

      Note that using G_DATA_STREAM_NEWLINE_TYPE_ANY is slightly unsafe. If a read
      chunk ends in "CR" we must read an additional byte to know if this is "CR" or
      "CR LF", and this might block if there is no more data available.
      Parameter:
      type - the type of new line return as #GDataStreamNewlineType.
    • asSeekable

      public Seekable asSeekable()
      Implements interface Seekable. Call this to get access to interface functions.
      Setzt außer Kraft:
      asSeekable in Klasse BufferedInputStream
      Gibt zurück:
      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()