参考 createWriter()

createWriter()

Creates a new p5.PrintWriter object.

p5.PrintWriter objects provide a way to save a sequence of text data, called the print stream, to the user's computer. They're low-level objects that enable precise control of text output. Functions such as saveStrings() and saveJSON() are easier to use for simple file saving.

The first parameter, filename, is the name of the file to be written. If a string is passed, as in createWriter('words.txt'), a new p5.PrintWriter object will be created that writes to a file named words.txt.

The second parameter, extension, is optional. If a string is passed, as in createWriter('words', 'csv'), the first parameter will be interpreted as the file name and the second parameter as the extension.

示例

语法

createWriter(name, [extension])

参数

name

name of the file to create.

extension

format to use for the file.

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

相关参考