Example: Read chars from a stream

public static int main (string[] args) {
// Opens "foo.txt" for reading ("r")
FileStream stream = FileStream.open ("filestream.vala", "r");
assert (stream != null);

// buffered:
char buf[100];
while (stream.gets (buf) != null) {
print ((string) buf);
}

return 0;
}

 valac --pkg glib-2.0 GLib.FileStream.gets.vala

See:




2022 vala-language.org