Java关于扫雷
这是我写的一个连连看游戏,用来做记录。供你自己参考,很简单。
导入Java . awt . point;
导入Java . io . *;
导入Java . util . *;
公共类LoadAndSave {
私有静态最终属性prop = new Properties();
公共静态文件record File = new File(" record . dat ");
公共静态文件setFile = new File(" setup . ini ");
公共静态StringBuilder[]set lines;
public static int get record(int total){
int秒= 999999999;
尝试{
buffered reader bReader = new buffered reader(new InputStreamReader(new file inputstream(record file)));
String line = null
while((line=bReader.readLine())!=空)
尝试{
string[]values = line . split(" \ t ");
int n = integer . parse int(values[1]);
int s = integer . parse int(values[2]);
if(n = = total & amp;& amps & lt秒)秒= s;
} catch (RuntimeException e) {
}
breader . close();
} catch(异常e) {
}
返回秒数;
}
公共静态空负载(){
尝试{
prop.loadFromXML(新文件输入流(setFile));
} catch(异常e) {
}
}
公共静态void save(){
尝试{
prop . storetoxml(new file output stream(setFile),“无注释”);
} catch(异常e) {
}
}
公共静态void saveLevel(int level){
prop.setProperty("level ",level+" ");
save();
}
公共静态void保存位置(点p) {
prop.setProperty("frameX ",p . x+" ");
prop.setProperty("frameY ",p . y+" ");
save();
}
public static void save record(int total,int seconds) {
尝试{
file output stream fos = new file output stream(record file,true);
PrintWriter out = new PrintWriter(fos,true);
out . println(new Date(system . current time millis())+" \ t "+total+" \ t "+秒);
out . close();
} catch(file not found exception e){
}
}
}