try {
Properties prop = new Properties();
File file = new File("con.ini");
if(file.exists()){
file.createNewFile();
}
FileInputStream fis = new FileInputStream(file);
prop.load(fis);
int count = 0;
String value = prop.getProperty("count");
if(value!=null){
count = Integer.parseInt(value);
}
if(count>5){
System.out.println("使用次数已到,拿钱!");
return;
}
count++;
prop.setProperty("count", count+"");
FileOutputStream fos = new FileOutputStream(file);
prop.store(fos, "");
fos.close();
fis.close();
} catch (IOException e) {
e.printStackTrace();
} |
|