File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change 1
1
package duke .main ;
2
2
3
+ import java .io .FileNotFoundException ;
3
4
import java .io .IOException ;
4
5
import java .util .Scanner ;
5
6
6
7
import duke .exceptions .*;
7
8
import duke .items .*;
8
9
10
+ import static duke .main .Utils .createFile ;
9
11
import static duke .main .Utils .loadFile ;
10
12
11
13
public class Duke {
@@ -16,8 +18,8 @@ public static void main(String[] args) {
16
18
Utils .printLine ();
17
19
try {
18
20
loadFile ();
19
- } catch (IOException e ) {
20
- e . printStackTrace ();
21
+ } catch (FileNotFoundException e ) {
22
+ createFile ();
21
23
}
22
24
Scanner in = new Scanner (System .in );
23
25
while (true ) {
Original file line number Diff line number Diff line change 1
1
package duke .main ;
2
2
3
3
import java .io .File ;
4
+ import java .io .FileNotFoundException ;
4
5
import java .util .ArrayList ;
5
6
import java .util .Arrays ;
6
7
import duke .exceptions .*;
@@ -78,7 +79,7 @@ public static void writeToFile() throws IOException {
78
79
fw .close ();
79
80
}
80
81
81
- public static void loadFile () throws IOException {
82
+ public static void loadFile () throws FileNotFoundException {
82
83
File f = new File ("list.txt" ); // create a File for the given file path
83
84
Scanner s = new Scanner (f ); // create a Scanner using the File as the source
84
85
while (s .hasNext ()) {
You can’t perform that action at this time.
0 commit comments