Referencia saveStrings()

saveStrings()

Saves an Array of Strings to a file, one per line.

The first parameter, list, is an array with the strings to save.

The second parameter, filename, is a string that sets the file's name. For example, calling saveStrings(['0', '01', '011'], 'data.txt') saves the array ['0', '01', '011'] to a file called data.txt on the user's computer.

The third parameter, extension, is optional. If a string is passed, as in saveStrings(['0', '01', '01'], 'data', 'txt')`, the second parameter will be interpreted as the file name and the third parameter as the extension.

The fourth parameter, isCRLF, is also optional, If true is passed, as in saveStrings(['0', '01', '011'], 'data', 'txt', true), then two characters, \r\n , will be added to the end of each string to create new lines in the saved file. \r is a carriage return (CR) and \n is a line feed (LF). By default, only \n (line feed) is added to each string in order to create new lines.

Note: The browser will either save the file immediately or prompt the user with a dialogue window.

Ejemplos

Sintaxis

saveStrings(list, filename, [extension], [isCRLF])

Parámetros

list
String[]:

data to save.

filename
String:

name of file to be saved.

extension
String:

format to use for the file.

isCRLF
Boolean:

whether to add \r\n to the end of each string. Defaults to false.

Notice any errors or typos? Please let us know. Please feel free to edit src/io/files.js and open a pull request!

Referencias Relacionadas