FileSystemManager.readFileSync
JS
FileSystemManager.readFileSync(
string filePath,
string encoding,
string position,
string length)Reads a file
The synchronous version of FileSystemManager.readFile
Parameters
| Property | Value Type | Description |
|---|---|---|
| filePath | string | Path of the file to read |
| encoding | string | Specifies the character encoding for reading the file. See the figure below for valid values. |
| position | number | Start 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 |
| length | number | Specifies the length of the file to read. If not specified, reading continues to the end of the file. Valid range: [1, fileLength]. Unit: byte |
Valid values of encoding:
| Value | Description |
|---|---|
| utf8 | utf-8 encoding |
| utf-8 | utf-8 encoding |
| binary | Binary |
Return Value
- string|ArrayBuffer data: File content
Parameters for caught exceptions
- string error: Returns error information. See the figure below for valid values.
Valid values of error:
| Error Information | Description |
|---|---|
| no such file or directory | The directory of the specified filePath does not exist |
