-
Notifications
You must be signed in to change notification settings - Fork 0
/
SaveData.java
49 lines (37 loc) · 990 Bytes
/
SaveData.java
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
47
48
49
package game;
import java.io.*;
import game.Game;
import game.io.*;
import static game.Console.*;
public final class SaveData
{
public static void write()
{
try{
File f = new File("save.dat");
LockedOutputStream fos = new LockedOutputStream(new FileOutputStream(f));
Game.loginedPlayer.s_write(fos);
fos.close();
f = new File("save.dat2");
LockedWriter fw = new LockedWriter(new FileWriter(f));
Game.loginedPlayer.s_writename(fw);
fw.close();
}catch(IOException ie){
error("セーブ時にエラーが発生しました");
}
}
public static boolean read()
{
try{
File f = new File("save.dat");
LockedInputStream fis = new LockedInputStream(new FileInputStream(f));
Game.loginedPlayer = new game.character.player.Player("");
Game.loginedPlayer.s_read(fis);
fis.close();
return true;
}catch(IOException ie){
error("セーブデータを読み込むときにエラーが発生しました");
return false;
}
}
}