forked from processing/processing-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtry.xml
More file actions
80 lines (62 loc) · 1.69 KB
/
try.xml
File metadata and controls
80 lines (62 loc) · 1.69 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<name>try</name>
<category>Structure</category>
<subcategory></subcategory>
<usage>Web & Application</usage>
<example>
<image></image>
<code><![CDATA[
BufferedReader reader;
String line;
void setup() {
// Open the file from the createWriter() example
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();
} else {
String[] pieces = split(line, TAB);
int x = int(pieces[0]);
int y = int(pieces[1]);
point(x, y);
}
}
]]></code>
</example>
<description><![CDATA[
The <b>try</b> keyword is used with <b>catch</b> to handle exceptions. Sun's Java documentation defines an exception as "an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions." This could be, for example, an error while a file is read.
]]></description>
<syntax>
try {
tryStatements
} catch (<c>exception</c>) {
catchStatements
}
</syntax>
<parameter>
<label>tryStatements</label>
<description><![CDATA[if this code throws an exception, then the code in "catch" is run]]></description>
</parameter>
<parameter>
<label>exception</label>
<description><![CDATA[the Java exception that was thrown]]></description>
</parameter>
<parameter>
<label>catchStatements</label>
<description><![CDATA[code that handles the exception]]></description>
</parameter>
<returns></returns>
<related></related>
<availability>1.0</availability>
<type>Keyword</type>
<partof>PDE</partof>
</root>