forked from processing/processing-web-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateWriter.xml
More file actions
executable file
·64 lines (47 loc) · 1.52 KB
/
Copy pathcreateWriter.xml
File metadata and controls
executable file
·64 lines (47 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<name>createWriter()</name>
<category>Output</category>
<subcategory>Files</subcategory>
<usage>Application</usage>
<example>
<image></image>
<code><![CDATA[
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
}
]]></code>
</example>
<description><![CDATA[
Creates a new file in the sketch folder, and a <b>PrintWriter</b> object to write to it. For the file to be made correctly, it should be flushed and must be closed with its <b>flush()</b> and <b>close()</b> methods (see above example).
<br/> <br/>
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.
]]></description>
<syntax><![CDATA[
createWriter(<kbd>filename</kbd>)
]]></syntax>
<parameter>
<label>filename</label>
<description><![CDATA[Name of the file to be created]]></description>
</parameter>
<returns>PrintWriter or null</returns>
<related>
PrintWriter
createReader
BufferedReader
</related>
<availability>1.0</availability>
<type>Function</type>
<partof>Core</partof>
</root>