forked from leehyelim0691/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoadFile.java
More file actions
32 lines (27 loc) · 698 Bytes
/
LoadFile.java
File metadata and controls
32 lines (27 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.io.*;
import java.util.*;
public class LoadFile{
private int money,rodLevel;
private String fileName,buffer;
private File file;
public LoadFile(){
fileName= "user.txt";
file = new File(fileName);
buffer = null;
money=0;
rodLevel=0;
}
public void play(){
try{
Scanner sc = new Scanner(file);
buffer = sc.nextLine();
Main.money = Integer.parseInt(buffer);
buffer = sc.nextLine();
Main.rodLevel = Integer.parseInt(buffer);
sc.close();
}
catch(FileNotFoundException e){
System.out.println("Error occurred while trying to read the file");
}
}
}