-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameSaveAndLoad.java
More file actions
46 lines (33 loc) · 886 Bytes
/
GameSaveAndLoad.java
File metadata and controls
46 lines (33 loc) · 886 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
public class GameSaveAndLoad {
public static Properties prop = new Properties();
public void saveGame(String point) {
try {
prop.setProperty("Save_Point", point);
prop.store(new FileOutputStream("config.prop"), null);
} catch (IOException e) {
}
}
public String loadGame() {
String line = "";
try {
prop.load(new FileInputStream("config.prop"));
line = prop.getProperty("Save_Point");
} catch (IOException e) {
try {
prop.setProperty("Save_Point", "0");
prop.store(new FileOutputStream("config.prop"), null);
try {
prop.load(new FileInputStream("config.prop"));
line = prop.getProperty("Save_Point");
} catch (IOException exe) {
}
} catch (IOException ex) {
}
}
return line;
}
}