62,634
社区成员




class RunCount
{
public static void main(String[] args) throws IOException
{
Properties prop = new Properties();
File file = new File("count.ini");
if(!file.exists())
file.createNewFile();
//FileOutputStream fos = new FileOutputStream(file);//在此处计数器始终为1次
FileInputStream fis = new FileInputStream(file);
prop.load(fis);
//FileOutputStream fos = new FileOutputStream(file);//在此处计数器到达五次后再执行会重新变回1次
int count = 0;
String value = prop.getProperty("time");
if(value!=null)
{
count = Integer.parseInt(value);
if(count>=5)
{
System.out.println("您好,使用次数已到.");
return ;
}
}
count++;
prop.setProperty("time",count+"");
FileOutputStream fos = new FileOutputStream(file);//在此处正常
prop.store(fos,"");
fos.close();
fis.close();
}
}