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

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 王运科 中级黑马   /  2012-3-30 20:52  /  1220 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

public class Propertise {

        public static void main(String[] args) throws IOException{               
                int times=0;
                File f=new File("E:\\count.ini");
                if(!f.exists())
                        f.createNewFile();
                FileInputStream fis=new FileInputStream(f);
                Properties pps=new Properties();
                pps.load(fis);
               
                String value=pps.getProperty("RunTimes");
                if(value!=null)
                        {
                        times=Integer.parseInt(value);
                        if(times>5)
                                {
                                System.out.println("对不起,您使用的次数已达5次,请交费使用!");
                                return;
                                }

                        }
                times++;
                pps.setProperty("RunTimes", times+"");
                FileOutputStream fw=new FileOutputStream(f);
                pps.store(fw,"运行次数");
                fis.close();
                fw.close();
        }
}

哪位大侠帮我运行一下,问题是:需要运行7次,才出现提示消息,不知道哪里错了。

1 个回复

倒序浏览
您需要登录后才可以回帖 登录 | 加入黑马