Skip to content

FileSystemManager.readFile ​

JS
    FileSystemManager.readFile(Object object)

Reads the content of a local file

Parameters

  • Object object: Input parameters. See the table below for details.

object properties:

PropertyValue TypeDefaultRequiredDescription
filePathstringYesPath of the file to read
encodingstringbinaryNoSpecifies the character encoding for reading the file. See the figure below for valid values.
positionnumberNoStart reading from the specified position in the file. If not specified, reading starts from the beginning of the file. The read range is the left-closed, right-open interval [position, position+length). Valid range: [0, fileLength - 1]. Unit: byte
lengthnumberNoSpecifies the length of the file to read. If not specified, reading continues to the end of the file. Valid range: [1, fileLength]. Unit: byte
successfunctionNoCallback for a successful call
failfunctionNoCallback for a failed call
completefunctionNoCallback for when the call ends

Valid values of encoding:

ValueDescription
utf8utf-8 encoding
utf-8utf-8 encoding
binaryBinary

Parameters of the success callback

  • Object res: Returns file information

res properties:

PropertyValue TypeDescription
datastring/ArrayBufferFile content