Skip to content

Commit 370f9d8

Browse files
committed
added xmlids to all of the code blocks from 8.1-8.4
1 parent 97dc160 commit 370f9d8

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

source/ch8_filehandling.ptx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
</datafile>
193193

194194

195-
<program interactive="activecode" language="java" add-files= "my-file">
195+
<program xml:id="file-read-exp1" interactive="activecode" language="java" add-files= "my-file">
196196
<code>
197197
import java.io.File;
198198
import java.io.FileNotFoundException;
@@ -220,7 +220,7 @@
220220
We will then create a new File object exactly the same as the one from the section on creating files. Additionally, we will create a Scanner object. The Scanner object is the object that does the file reading. We will call this scanner fileReader:
221221
</p>
222222

223-
<program interactive="activecode" language="java">
223+
<program xml:id="file-read-exp2" interactive="activecode" language="java">
224224
<code>
225225
import java.io.File;
226226
import java.io.FileNotFoundException;
@@ -248,7 +248,7 @@
248248
The next lines consists of a Python code example that reads each line of the file passed to the Scanner object.:
249249
</p>
250250

251-
<program interactive="activecode" language="python" add-files="my-file">
251+
<program xml:id="file-read-exp3" interactive="activecode" language="python" add-files="my-file">
252252
<code>
253253
with open("myfile.txt", "r") as file_reader:
254254
for line in file_reader:
@@ -260,7 +260,7 @@
260260
The equivalent Java code:
261261
</p>
262262

263-
<program interactive="activecode" language="java" add-files= "my-file">
263+
<program xml:id="file-read-exp4" interactive="activecode" language="java" add-files= "my-file">
264264
<code>
265265
import java.io.File;
266266
import java.io.FileNotFoundException;
@@ -289,7 +289,7 @@
289289
Alternatively, the following code can be used to store the all lines of myfile.txt to one variable:
290290
</p>
291291

292-
<program interactive="activecode" language="java" add-files="my-file">
292+
<program xml:id="file-read-exp5" interactive="activecode" language="java" add-files="my-file">
293293
<code>
294294
import java.io.File;
295295
import java.io.FileNotFoundException;
@@ -321,7 +321,7 @@
321321
Using the second method of storing all file contents to one file, the resulting full code including try/catch blocks (this time using FileNotFoundException instead of IOException) will look something like this. First, the Python code:
322322
</p>
323323

324-
<program interactive="activecode" language="python">
324+
<program xml:id="file-read-exp6" interactive="activecode" language="python">
325325
<code>
326326
try:
327327
with open("myfile.txt", "r") as file_reader:
@@ -341,7 +341,7 @@
341341
And the Java equivalent:
342342
</p>
343343

344-
<program interactive="activecode" language="java" add-files="my-file">
344+
<program xml:id="file-read-exp7" interactive="activecode" language="java" add-files="my-file">
345345
<code>
346346
import java.io.File;
347347
import java.io.FileNotFoundException;
@@ -382,7 +382,7 @@
382382
Let us create the framework for a class that will write to a file. Let's call this class <c>WriteFile</c>:
383383
</p>
384384

385-
<program interactive="activecode" language="java">
385+
<program xml:id="file-write-exp1" interactive="activecode" language="java">
386386
<code>
387387
import java.io.File;
388388
import java.io.FileWriter;
@@ -444,7 +444,7 @@
444444
3
445445
</pre>
446446
</datafile>
447-
<program interactive="activecode" language="python" add-files = "my-file-8-4-2">
447+
<program xml:id="file-write-exp2" interactive="activecode" language="python" add-files = "my-file-8-4-2">
448448
<code>
449449
with open("myfile8-4-2.txt", "r") as file_reader:
450450
while True:
@@ -463,7 +463,7 @@
463463

464464
</pre>
465465
</datafile>
466-
<program interactive="activecode" language="java" add-files = "my-file-8-4-3">
466+
<program xml:id="file-write-exp3" interactive="activecode" language="java" add-files = "my-file-8-4-3">
467467
<code>
468468
import java.io.File;
469469
import java.io.IOException;
@@ -491,7 +491,7 @@
491491

492492
</pre>
493493
</datafile>
494-
<program interactive="activecode" language="python" add-files = "my-file-8-4-4">
494+
<program xml:id="file-write-exp4" interactive="activecode" language="python" add-files = "my-file-8-4-4">
495495
<code>
496496
try:
497497
with open("myfile.txt", "w") as my_writer:
@@ -512,7 +512,7 @@
512512

513513
</pre>
514514
</datafile>
515-
<program interactive="activecode" language="java" add-files = "my-file-8-4-5">
515+
<program xml:id="file-write-exp5" interactive="activecode" language="java" add-files = "my-file-8-4-5">
516516
<code>
517517
import java.io.FileWriter;
518518
import java.io.IOException;
@@ -559,7 +559,7 @@
559559

560560
</pre>
561561
</datafile>
562-
<program interactive="activecode" language="java" add-files = "my-file-8-4-6">
562+
<program xml:id="file-write-exp6" interactive="activecode" language="java" add-files = "my-file-8-4-6">
563563
<code>
564564
import java.io.FileWriter;
565565
import java.io.IOException;

0 commit comments

Comments
 (0)