用于记录应用程序运行次数 如果使用次数已到那么给出注册提示
import java.io.*;
import java.util.*;
class PropertiesDemo5
{
public static void main(String[] args) throws Exception
{Properties pt=new Properties();
File f=new File("count.Properties");
if(!f.exists())
f.createNewFile();
FileInputStream fis=new FileInputStream(f);
pt.load(fis);
String value=pt.getProperty("time");
int count=0;
if(value!=null)
{count=Integer.parseInt(value);
if(count>=5)
System.out.println("次数已到请交钱");
return;
count++;
pt.setProperty("time",count+"");
}
FileOutputStream fos=new FileOutputStream(f);
pt.store(fos,"");
fos.close();
fis.close();
}
}
|