Search processing.org:

Reference for Processing (BETA) version 0135+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Name | ### createWriter()
Examples |
    PrintWriter output;

    void setup() {
      // Create a new file in the sketch directory
      output = createWriter("positions.txt");
    }

    void draw() {
      point(mouseX, mouseY);
      output.println(mouseX + "t" + mouseY); // Write the coordinate to the file
    }

    void keyPressed() {
      output.flush(); // Writes the remaining data to the file
      output.close(); // Finishes the file
      exit(); // Stops the program
    }
Description | 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.
Syntax |
    createWriter(filename)
Parameters |
filename | Name of the file to be created
Usage | Application
Related | PrintWriter createReader BufferedReader

Updated on November 17, 2007 10:07:52am PST