FileSystemManager.readFileSync

Requires:
BaseKit≥2.0.1
Platforms:
iOSAndroid

Method signature
FileSystemManager.readFileSync(req?: )

Description

Read the contents of a local file

Parameters

ParameterTypeRequiredDescription
NoParameter object

Return Value

Type: Object↓
PropertyTypeDescription
datastringFile content

Examples

import { getFileSystemManager } from '@ray-js/ray'

// Write a file first to ensure there is something to read.
const fm = await getFileSystemManager();

fm.writeFile({
  filePath: "thingfile://usr/ttt_demo.txt",
  data: "hello ttt",
  success: () => {
    fm.readFile({
      filePath: "thingfile://usr/ttt_demo.txt",
      encoding: "utf8",
      success: data => {
        console.log(data);
      },
      fail: error => {
        console.error(error);
      },
    });
  },
  fail: error => {
    console.error(error);
  },
});