首页 > 文档 > PrintWriter打印文本输出
2017
08-02

PrintWriter打印文本输出

Name

PrintWriter打印文本输出

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

Allows characters to print to a text-output stream. A new PrintWriter object is created with the createWriter() function. For the file to be made correctly, it should be flushed and must be closed with its flush() and close() methods (see above example).

允许字符打印到文本输出流。使用 createWriter () 函数创建一个新的 PrintWriter 对象。为了使文件能够正确地进行, 它应该被刷新, 并且必须用它的刷新 () close () 方法关闭 (请参见上面的示例)

Methods

print()

Adds data to the stream

println()

Adds data to the stream and starts a new line

flush()

Flushes the stream

close()

Closes the stream

Constructor


 

Related

createWriter()



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

留下一个回复

你的email不会被公开。