Reference 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.

Examples

Syntax

createWriter(name, [extension])

Parameters

name
String:

name of the file to create.

extension
String:

format to use for the file.

Returns

p5.PrintWriter: stream for writing data.
Notice any errors or typos? Please let us know. Please feel free to edit src/io/files.js and open a pull request!

Related References