A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 途中ms前进 中级黑马   /  2015-6-1 17:52  /  835 人查看  /  5 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

用于记录应用程序运行次数 如果使用次数已到那么给出注册提示

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

评分

参与人数 1技术分 +1 收起 理由
lwj123 + 1

查看全部评分

5 个回复

倒序浏览
顶~ 不过一般软件都以使用天数来判断。
回复 使用道具 举报
谢谢分享,加点注释最好了
回复 使用道具 举报
恩,加油吧!!!!!
回复 使用道具 举报
配置文件很容易就让人破解啊
回复 使用道具 举报
加点注释最好了

还有就是代码格式应该在格式化一下,看起来不方便
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马