黑马程序员技术交流社区

标题: 自个写个小程序,登录3次,需缴费 [打印本页]

作者: yangshaoqiang    时间: 2015-10-28 21:25
标题: 自个写个小程序,登录3次,需缴费
{:2_32:}
public class Demo3 {
        public static void main(String[] args) throws IOException {
                System.out.println("Welcom");
                String str=System.getProperty("user.home");
                File file=new File(str+"\\soft.propreties");
                if(!file.exists()){
                        file.createNewFile();
                }
                Properties pro=new Properties();
                pro.load(new FileInputStream(file));
                String c=pro.getProperty("count");
                int count=1;
                if(c==null){
                        pro.setProperty("count", "1");
                }else{
                        count=Integer.valueOf(c);
                        if(count>=3){
                                System.out.println("试用到期,请缴费");
                                System.exit(0);
                        }else{
                                count++;
                                pro.setProperty("count", String.valueOf(count));
                        }
                }
                System.out.println("使用"+pro.getProperty("count")+"次");
                FileOutputStream fos=new FileOutputStream(file);
                pro.store(fos, "soft");
                fos.close();
        }
}
作者: 熊金磊    时间: 2015-10-28 21:33
有注释就好多了!
作者: 我若为神    时间: 2015-10-28 21:37
麻烦加点注释吧
作者: jyf823691221    时间: 2015-10-28 21:41
看不懂  看不懂~
作者: yangshaoqiang    时间: 2015-10-28 21:48
不好意思啊,老忘记注释




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2