62,621
社区成员
发帖
与我相关
我的任务
分享package OterDemo;
import java.io.*;
import java.util.Properties;
public class RunCountDemo {
public static void main(String[] args) throws IOException {
Properties prop = new Properties();
File file = new File("count.ini");
if(!file.exists())
file.createNewFile();
FileReader fr = new FileReader(file);
FileWriter fw = new FileWriter(file);
prop.load(fr);
String value = prop.getProperty("time");[code=java] int count=0;
if(value != null) {
count = Integer.parseInt(value);
if (count >= 3) {
System.out.println("u can not use it anymore");
return;
}
}
count++;
prop.setProperty("time", count + "");
prop.store(fw, "");
fw.close();
fr.close();
}
}[/code]