/*
* 程序头部注释开始
* 程序的版权和版本声明部分
* Copyright (c) 2011, 烟台大学计算机学院学生
* All rights reserved.
* 文件名称:配置文件
* 作 者:薛广晨
* 完成日期:2012 年 11 月 10 日
* 版 本号:x1.0
* 对任务及求解方法的描述部分
* 输入描述:
* 问题描述:用于记录应用程序运行次数。
如果使用次数已到,那么给出注册提示
* 程序输出:
* 程序头部的注释结束
*/
import java.io.*;
import java.util.*;
class RunCount
{
public static void main(String[] args) throws IOException
{
Properties prop = new Properties();
File file = new File("info.ini");
if(!file.exists())
file.createNewFile();
FileInputStream fis = new FileInputStream(file);
prop.load(fis);
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, "");
fis.close();
fos.close();
}
}
配置文件
最新推荐文章于 2024-04-27 23:49:54 发布