Skip to content

Commit 29827e3

Browse files
nshizirungudieumerci@gmail.comnshizirungudieumerci@gmail.com
authored andcommitted
added listing tags to the appropriate places and in the appropriate paragraphs.
1 parent c116c55 commit 29827e3

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

source/ch8_filehandling.ptx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,10 @@ public class CreateFile {
449449
<title>Deleting Files</title>
450450

451451
<p>
452-
Lastly, we will take a look at using Java to delete a file. This is pretty straight-forward and follows the structure used to create files. Here is the <c>CreateFile</c> class from before that will be used to create a file that we will soon delete:
452+
Lastly, we will take a look at using Java to delete a file. This is pretty straight-forward and follows the structure used to create files. <xref ref="create-file-to-delete-java" text="type-global"/> shows the <c>CreateFile</c> class from before that will be used to create a file that we will soon delete:
453453
</p>
454454

455-
<program xml:id="create-file-to-delete-java" interactive="activecode" language="java">
455+
<listing xml:id="create-file-to-delete-java"> <program interactive="activecode" language="java">
456456
<code>
457457
import java.io.File;
458458
import java.io.IOException;
@@ -475,15 +475,17 @@ public class CreateFile {
475475
}
476476
</code>
477477
</program>
478+
</listing>
478479

479480

480481
<p>
481-
And finally, we have Java code that deletes a file. We will call this class <c>DeleteFile</c>:
482+
And finally, <xref ref="delete-file-java" text="type-global"/> shows the Java code that deletes a file. We will call this class <c>DeleteFile</c>:
482483
</p>
483484

484485

485-
<program xml:id="delete-file-java" interactive="activecode" language="java">
486-
<code>
486+
<listing xml:id="delete-file-java">
487+
<program interactive="activecode" language="java">
488+
<code>
487489
import java.io.File;
488490
import java.io.IOException;
489491

@@ -508,7 +510,7 @@ public class DeleteFile {
508510

509511
</code>
510512
</program>
511-
513+
</listing>
512514
<p>
513515
Note that this is almost identical to the code within the <c>try</c> block of the <c>CreateFile</c> class that we made earlier. The key difference is the use of the <c>delete()</c> method which will delete the file with the name that was linked to the myFile object. Similar to the <c>createNewFile()</c> method, it will return <c>true</c> if the file exists and can be deleted, and <c>false</c> if the file cannot be deleted.
514516
</p>

0 commit comments

Comments
 (0)