Skip to content

Commit 3187210

Browse files
authored
Merge pull request #128 from coco3427/ch8.1
moved the introduction to 8.1 and added an explanation for the third code block.
2 parents f973c3e + 14a208a commit 3187210

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

source/ch8_filehandling.ptx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@
44
<chapter xml:id="filemmanipulation">
55
<title>File Handling</title>
66

7-
<introduction>
8-
<p>
9-
File handling is an integral part of programming. Most programming languages have the ability to read from, write to, create, delete, move, and copy files.
10-
</p>
11-
</introduction>
12-
13-
147
<section xml:id="file-class-import">
158
<title>Class Imports</title>
169
<p>
17-
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 read from, write to, create, delete, move, and copy 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.
1811
</p>
1912
<program xml:id = "file-class-import-Python-example" interactive="activecode" language="python">
2013
<code>
@@ -42,12 +35,13 @@
4235
</p>
4336

4437
<p>
45-
Java includes a class called <c>File</c> in the <c>io</c> library. The class can be imported with the following line. Be sure to capitalize <c>File</c>.
38+
Much like the Math class, in order for your program to work with files you need to import classes from libraries. Java includes a class called <c>File</c> in the <c>io</c> library. This class allows you to create File objects, and use its public methods. the following code imports the <c>File</c> class and creates a <c>File</c> object called myFile. for now focus on how the class is imported and used in the program; We will cover the <c>IOException</c> class and <c>createNewFile</c> method later.
4639
</p>
4740
<program xml:id = "file-class-import-io-example" interactive="activecode" language="java">
4841
<code>
4942
import java.io.File;
50-
import java.io.IOException;public class Main {
43+
import java.io.IOException;
44+
public class Main {
5145
public static void main(String[] args) {
5246
try {
5347
File myFile = new File("newfile.txt");

0 commit comments

Comments
 (0)