file get contents

程式碼

#!/usr/bin/env gjs

const Lang = imports.lang;
const GLib = imports.gi.GLib;

try {
    let [ok, content] = GLib.file_get_contents("data.txt");
    if (ok) {
        print(content);
    }
} catch (e) {
    print("Error: ", e.message);
}

Api