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 |
|
||||
Returns |
PrintWriter |
||||
Related |
- 本文固定链接: http://iprocessing.cn/2017/08/02/createwriter创建文本/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表