3-1.BufferedReader
Name(名称):BufferedReader//读取文件
Examples(例子):
BufferedReader reader;
String line;
void setup() {
// Open the file from the createWriter() example从createWriter()示例中打开文件
reader = createReader(“positions.txt”);
}
void draw() {
try {
line = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
line = null;
}
if (line == null) {
// Stop reading because of an error or file is empty停止读取,因为错误或文件是空的
noLoop();
} else {
String[] pieces = split(line, TAB);
int x = int(pieces[0]);
int y = int(pieces[1]);
point(x, y);
}
}
Description(描述):A BufferedReader object is used to read files line-by-line as individual String objects.
BufferedReader对象用于逐行读取文件作为单个String对象。
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.
从处理版本0134开始,Processing API加载和保存的所有文件都使用UTF-8编码。 在以前的版本中,使用了您的平台的默认编码,当文件移动到其他平台时,会导致问题。
Related(相关函数):createReader()
try
catch
- 本文固定链接: http://iprocessing.cn/2017/07/14/bufferedreader缓冲读取文件/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表