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

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 自己玩 黑马帝   /  2012-2-19 16:06  /  1758 人查看  /  3 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 自己玩 于 2012-2-19 17:52 编辑

就是在看毕老师第二十天的视频时,关于一下代码中
import java.io.*;
import java.util.*;
class  RunCount
{
        public static void main(String[] args) throws IOException
        {
                Properties prop = new Properties();

                File file = new File("count.ini");//??为什么把文件明count.ini变为con或con.扩展名  后运行的结果不同了????
                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,"");

                fos.close();
                fis.close();
               
        }
}
大家说说这是为什么?最好说详细点,谢谢!!

评分

参与人数 1技术分 +1 收起 理由
唐秀启 + 1

查看全部评分

3 个回复

倒序浏览
一般来说,ini文件是保存配置信息的,共享软件就是如此
扩展名为.con的文件是一个Web文件

建议楼主谷歌下

评分

参与人数 1技术分 +1 收起 理由
唐秀启 + 1

查看全部评分

回复 使用道具 举报
原来CON是DOS下的特殊设备名
回复 使用道具 举报
Properties看一下在java中load方法的说明了,个人感觉,因为在网吧,所以不想查了
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马