package namespace;
import java.awt.FileDialog;
import java.io.*;
import java.util.*;
public class IOTest {
public static void main(String args[]) throws IOException
{
Properties pro = new Properties();
File file = new File ("F:\\count.ini");
if(!file.exists()) {
file.createNewFile();
}
FileInputStream reader = new FileInputStream(file);
pro.load(reader);
String time = pro.getProperty("time");
int count=0;
if(time != null)
count=Integer.parseInt(time);
count++;
if(count>=5)
{
System.out.println("您的试用次数已到,拿钱吧....");
System.exit(1);
}
pro.setProperty("time",count+"");
FileOutputStream writer = new FileOutputStream(file);//写文件在打开的时候要看准时机,要在读完的时候再打开,不然会出现想不到的错误
pro.store(writer,"count");
writer.close();
reader.close();
System.out.println("Welcome...&
Java 判断程序运行次数---- Properties 文件计数器
最新推荐文章于 2018-01-27 13:06:13 发布