BufferedInputStream
Object Hierarchy:
GLib.BufferedInputStream
GLib.BufferedInputStream
GLib.BufferedInputStream
GLib.FilterInputStream
GLib.FilterInputStream
GLib.FilterInputStream->GLib.BufferedInputStream
GLib.InputStream
GLib.InputStream
GLib.InputStream->GLib.FilterInputStream
GLib.Object
GLib.Object
GLib.Object->GLib.InputStream
GLib.Seekable
GLib.Seekable
GLib.Seekable->GLib.BufferedInputStream
Description:
[
CCode ( type_id =
"g_buffered_input_stream_get_type ()" ) ]
public class BufferedInputStream :
FilterInputStream ,
Seekable
Buffered input stream implements FilterInputStream and provides for
buffered reads.
By default, BufferedInputStream 's buffer size is set at 4 kilobytes.
To create a buffered input stream, use
BufferedInputStream , or
BufferedInputStream.sized to specify the buffer's size at construction.
To get the size of a buffer within a buffered input stream, use
get_buffer_size . To change the size of a buffered input stream's buffer, use
set_buffer_size . Note that the buffer's size cannot be reduced
below the size of the data within the buffer.
Example: Buffered input-streams:
public static int main (string [] args) { if (args.length < 2 ) { print ("Usage: %s FILE \n " , args[0 ]); return 0 ; } File infile = File.new_for_commandline_arg (args[1 ]); if (!infile.query_exists ()) { stderr.printf ("File ' %s ' does not exist. \n " , args[1 ]); return 1 ; } try { FileInputStream @is = infile.read (); BufferedInputStream bis = new BufferedInputStream (@is); StringBuilder builder = new StringBuilder (); uint8 buffer[100 ]; ssize_t size; while ((size = bis.read (buffer)) > 0 ) { builder.append_len ((string ) buffer, size); } print (builder.str); } catch (Error e) { stderr.printf ("Error: %s " , e.message); return -1 ; } return 0 ; }
valac --pkg gio-2.0 GLib.BufferedInputStream.vala
Content:
Properties:
Creation methods:
Methods:
public virtual ssize_t fill (ssize_t count, Cancellable ? cancellable = null ) throws Error
Tries to read count
bytes from the stream into the
buffer.
public virtual async ssize_t fill_async (ssize_t count, int io_priority = DEFAULT , Cancellable ? cancellable = null ) throws Error
Reads data into this 's buffer
asynchronously, up to count
size.
public size_t get_available ()
Gets the size of the available data within the stream.
public size_t get_buffer_size ()
Gets the size of the input buffer.
public size_t peek (uint8 [] buffer, size_t offset = 0 )
Peeks in the buffer, copying data of size buffer.length
into buffer
, offset offset
bytes.
public unowned uint8 [] peek_buffer ()
Returns the buffer with the currently available bytes.
public int read_byte (Cancellable ? cancellable = null ) throws Error
Tries to read a single byte from the stream or the buffer.
public void set_buffer_size (size_t size)
Sets the size of the internal buffer of
this to size
, or to the size of the contents of the buffer.
Inherited Members:
All known members inherited from class GLib.FilterInputStream
All known members inherited from class GLib.InputStream
All known members inherited from class GLib.Object
@get
@new
@ref
@set
add_toggle_ref
add_weak_pointer
bind_property
connect
constructed
disconnect
dispose
dup_data
dup_qdata
force_floating
freeze_notify
get_class
get_data
get_property
get_qdata
get_type
getv
interface_find_property
interface_install_property
interface_list_properties
is_floating
new_valist
new_with_properties
newv
notify
notify_property
ref_count
ref_sink
remove_toggle_ref
remove_weak_pointer
replace_data
replace_qdata
set_data
set_data_full
set_property
set_qdata
set_qdata_full
set_valist
setv
steal_data
steal_qdata
thaw_notify
unref
watch_closure
weak_ref
weak_unref
All known members inherited from interface GLib.Seekable