import java.io.*;
import java.util.*;
class AppDomeTime
{
public static void main(String[] args) throws IOException
{
Properties prop = new Properties();
File file = new File("count.ini");
if(!file.exists())
file.createNewFile();
FileInputStream fis = new FileInputStream(file);
//FileOutputStream fos = new FileOutputStream(file);
//在这里定义输出流,程序可以重复运行,而不出现次数已到的提示.
prop.load(fis);
int count = 0;
String value = prop.getProperty("time");
if(value!=null)
{
count = Integer.parseInt(value);
if(count>=2)
{
System.out.println("试用次数已到,请购买此程序再次使用!");
return;
}
}
count++;
prop.setProperty("time",count+"");
FileOutputStream fos = new FileOutputStream(file);
//为什么在这里定义输出流对象,程序运行两次后就可输出次数已到.
prop.store(fos,"open");
fis.close();
fos.close();
}
|
|