IO.write

Writes the string to the specified file. If the file does not exist, it is created.

IO.write(fileName, fileContent, append, charset);

Arguments

Name Description
filename(string) The absolute path of the file.
input(string) String to write to the file.

append

(Optional)

(boolean) Indicates whether to append the string or overwrite the existing file contents:

  • true. Append the string to the end of the file (default).

  • false. Overwrite the file with the string.

charset

(Optional)

(string) The charset of the file, if it is not UTF-8.

Supported charsets: ['binary', 'UTF-8', 'UTF-16', 'base64', 'ANSI']

Return value

A promise fulfilled with true upon success.

Example

Copy code
(async ()=>{
    let ret = await IO.write("file_path", "This is first line\n", false);
})();