首页 > 文档 > createReader()创建读取
2017
07-14

createReader()创建读取

3-3.createReader()

Name(名称):createReader()//读取文件

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();

reader.close();

} else {

String[] pieces = split(line, TAB);

int x = int(pieces[0]);

int y = int(pieces[1]);

point(x, y);

}

}

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.

创建一个BufferedReader对象,可用于逐行读取文件作为单个String对象。 这是对createWriter()函数的补充。 有关BufferedReader类及其上述示例中使用的readLine()和close的方法的更多信息,请参考Java参考。

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编码。 在以前的版本中,使用了您的平台的默认编码,当文件移动到其他平台时,会导致问题。

Syntax(语法):createReader(filename)

Parameters (参数):filename——要打开的文件的名称

Returns(返回值):BufferedReader

Related(相关函数):createWriter()

 


 



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。