Skip to content

Commit b51dc8d

Browse files
committed
added listing to txt
1 parent 6d385b4 commit b51dc8d

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

source/ch8_filehandling.ptx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<section xml:id="class-imports">
88
<title>Class Imports</title>
99
<p>
10-
File handling is an integral part of programming. Most programming languages have the ability to create, read from, write to, and delete, files. In Python, most built-in libraries are available without needing to explicitly import additional packages, but some libraries like <c>math</c> do need to be imported. Consider the following.
10+
File handling is an integral part of programming. Most programming languages have the ability to create, read from, write to, and delete, files. In Python, most built-in libraries are available without needing to explicitly import additional packages, but some libraries like <c>math</c> do need to be imported. <xref ref="file-class-import-Python-example" text="type-global"/> shows an example of importing the <c>math</c> library in Python.
1111
</p>
1212

1313
<listing xml:id = "file-class-import-Python-example">
@@ -20,10 +20,10 @@
2020
</listing>
2121

2222
<p>
23-
Delete the first line that says <c>import math</c> and see what happens. The <c>import math</c> is needed. The same program in Java would look like this:
23+
Delete the first line that says <c>import math</c> and see what happens. The <c>import math</c> is needed. The same program in Java would look like <xref ref="file-class-import-Java-example" text="type-global"/>.
2424
</p>
2525

26-
<listing xml:id = "file-class-import-Java-example">
26+
<listing xml:id ="file-class-import-Java-example">
2727
<program interactive="activecode" language="java">
2828
<code>
2929
import java.lang.Math;
@@ -42,7 +42,7 @@
4242
</p>
4343

4444
<p>
45-
Much like the <c>Math</c> class, in order for your program to work with files you need use <c>import</c>. Java includes a class called <c>File</c> in the <c>io</c> library. This class allows you to create <c>File</c> objects, and use its public methods.
45+
Much like the <c>Math</c> class, in order for your program to work with files you need use <c>import</c>. Java includes a class called <c>File</c> in the <c>io</c> library shown in <xref ref="io-file-import" text="type-global"/>. This class allows you to create <c>File</c> objects, and use its public methods.
4646
</p>
4747

4848
<listing xml:id = "io-file-import">
@@ -52,7 +52,7 @@
5252
</listing>
5353

5454
<p>
55-
The <c>Scanner</c> class from the <c>util</c> library will need to be imported if there is any need for a program to read a file. It should be noted that this library is unnecessary if the program will not be reading any data from a file.
55+
The <c>Scanner</c> class from the <c>util</c> library will need to be imported if there is any need for a program to read a file as shown in <xref ref="util-scanner-import" text="type-global"/>. It should be noted that this library is unnecessary if the program will not be reading any data from a file.
5656
</p>
5757
<listing xml:id = "util-scanner-import">
5858
<program>
@@ -61,7 +61,7 @@
6161
</listing>
6262

6363
<p>
64-
The <c>FileWriter</c> class can be used to write to files. In the same way that the <c>Scanner</c> class isn't needed unless the program will read from a file, the <c>FileWriter</c> class isn't needed unless the program will write to a file.
64+
The <c>FileWriter</c> class can be used to write to files as shown in <xref ref="io-filewriter-import" text="type-global"/>. In the same way that the <c>Scanner</c> class isn't needed unless the program will read from a file, the <c>FileWriter</c> class isn't needed unless the program will write to a file.
6565
</p>
6666

6767
<listing xml:id = "io-filewriter-import">
@@ -71,7 +71,7 @@
7171
</listing>
7272

7373
<p>
74-
Finally, these last two classes provide error handling and must be used in tandem with the <c>File</c> class when reading from or writing to files. <c>IOException</c> handles file creation and writing errors, while <c>FileNotFoundException</c> handles errors when trying to read files.
74+
Finally, these last two classes provide error handling and must be used in tandem with the <c>File</c> class when reading from or writing to files as shown in <xref ref="io-exception-imports" text="type-global"/>. <c>IOException</c> handles file creation and writing errors, while <c>FileNotFoundException</c> handles errors when trying to read files.
7575
</p>
7676

7777
<listing xml:id = "io-exception-imports">

0 commit comments

Comments
 (0)