Skip to content

Commit 4c9d26c

Browse files
committed
Changed the code block about writing to files in section 8.1 to pre tags, and removed all code except for the File class import. This pretag code block and the paragaph preceding it focus exclusively on importing the File class now.
1 parent b586f9a commit 4c9d26c

1 file changed

Lines changed: 7 additions & 17 deletions

File tree

source/ch8_filehandling.ptx

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,14 @@
3737
<p>
3838
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. 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.
3939
</p>
40-
<program xml:id = "file-class-import-io-example" interactive="activecode" language="java">
41-
<code>
42-
import java.io.File;
43-
import java.io.IOException;
44-
public class Main {
45-
public static void main(String[] args) {
46-
try {
47-
File myFile = new File("newfile.txt");
48-
myFile.createNewFile();
49-
System.out.println("File Made.");
50-
} catch (IOException e) {
51-
System.out.println("An error occurred.");
52-
}
53-
}
54-
}
55-
</code>
56-
</program>
5740

41+
<p>
42+
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.
43+
</p>
44+
45+
<pre>
46+
import java.io.File;
47+
</pre>
5848
<p>
5949
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.
6050
</p>

0 commit comments

Comments
 (0)