Fork me on GitHub
beagleboard.org

BoneScript

You might be able to see a newer version of this on beagleboard.org/support/bonescript/readTextFile

readTextFile(filename, [callback])

Read the contents of a text (ASCII) file.

Arguments

  • filename: complete path of the file to be read
  • callback: called upon completion

Return value

  • File contents in a single string

callback(x)

  • x.data: file contents
  • x.err: error status message

Example

var b = require('bonescript');
b.readTextFile('/etc/dogtag', printStatus);
function printStatus(x) {
    console.log('x.data = ' + x.data);
    console.log('x.err = ' + x.err);
}

Build and execute instructions

  • Adjust the file name to read other files and execute the example code.

See also

Related functions

Examples