BufferedInputStream
Object Hierarchy:
Description:
[ CCode ( type_id = "g_buffered_input_stream_get_type ()" ) ]
public class BufferedInputStream : FilterInputStream, Seekable
public class BufferedInputStream : FilterInputStream, Seekable
Buffered input stream implements FilterInputStream and provides for buffered reads.
By default, `GBufferedInputStream`'s buffer size is set at 4 kilobytes.
To create a buffered input stream, use [ctor@Gio.BufferedInputStream.new], or [ctor@Gio.BufferedInputStream.new_sized] to specify the buffer's size at construction.
To get the size of a buffer within a buffered input stream, use [method@Gio.BufferedInputStream.get_buffer_size]. To change the size of a buffered input stream's buffer, use [method@Gio.BufferedInputStream.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
All known sub-classes:
Namespace: GLib
Package: gio-2.0
Content:
Properties:
Creation methods:
Methods:
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
All known members inherited from interface GLib.Seekable