Example: Map a file and print its content and size

public static int main (string[] args) {
try {
MappedFile file = new MappedFile ("test.vala", false);
print ((string) file.get_contents ());
print ("Size: %" + size_t.FORMAT + " bytes\n", file.get_length ());
} catch (FileError e) {
print ("FileError: %s\n", e.message);
}
return 0;
}

 valac --pkg glib-2.0 GLib.MappedFile.vala

See:




2022 vala-language.org