- Processing
- p5.js
- Processing.py
- Processing for Android

- Processing Foundation

This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Name | ### createReader()
Examples |
    void setup() {
      size(100, 100);
      parseFile();
    }

    void parseFile() {
      // Open the file from the createWriter() example
      BufferedReader reader = createReader("positions.txt");
      String line = null;
      try {
        while ((line = reader.readLine()) != null) {
          String[] pieces = split(line, TAB);
          int x = int(pieces[0]);
          int y = int(pieces[1]);
          point(x, y);
        }
        reader.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
Description | Creates a BufferedReader object that can be used to read files line-by-line as individual String objects. This is the complement to the createWriter() function. For more information about the BufferedReader class and its methods like readLine() and close used in the above example, please consult a Java reference. 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 |
    createReader(filename)
Parameters |
filename | String: name of the file to be opened
Returns | BufferedReader
Related | createWriter()

Updated on November 10, 2017 05:36:28pm EST