首页 > 文档 > createWriter()创建文本
2017
08-02

createWriter()创建文本

Name

createWriter()创建文本

   

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 + “t” + mouseY); // 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

Creates a new file in the sketch folder, and a PrintWriter object to write to it. For the file to be made correctly, it should be flushed and must be closed with its flush() and close() methods (see above example). 

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.

草绘文件夹中创建一个新文件, 并在其中写入一个 PrintWriter 对象。为了使文件能够正确地进行, 它应该被刷新, 并且必须用它的刷新 () close () 方法关闭 (请参见上面的示例)

 

从处理版本0134开始, 处理 api 加载和保存的所有文件都使用 UTF-8 编码。在以前的版本中, 使用了您的平台的默认编码, 这会导致文件移动到其他平台时出现问题。

Syntax

createWriter(filename)

Parameters

filename

String: name of the file to be created

 

要创建文件的名称

Returns

PrintWriter

Related

createReader()



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

留下一个回复

你的email不会被公开。