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();
}
}
|
|