Reference+
Name
createReader()
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.
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(); } }
Syntax
createReader(filename)
Parameters
filename
(String)
name of the file to be opened
Return
BufferedReader
Related
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.