# Create a file in the sketch directory output = createWriter("positions.txt") numbers = [17, 34, 190, 4, 18, 12] for item in numbers: output.print(item) # Write the datum to the file output.flush()# Writes the remaining data to the file output.close()# Finishes the file exit()# Stops the program
Creates a new file in the sketch folder, and a PrintWriter object to write to it. For the file to be made correctly, it should be flushed and must be closed with its flush() and close() methods (see above example).
Starting with Processing release 0134, all files loaded and saved by the Processing API use UTF-8 encoding. In previous releases, the default encoding for your platform was used, which causes problems when files are moved to other platforms.
output = createWriter(fileName)
Updated on Mon Sep 21 15:53:24 2020.
If you see any errors or have comments, please let us know.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License