黑马程序员技术交流社区

标题: Proerties [打印本页]

作者: Bule丶    时间: 2014-8-1 14:24
标题: Proerties
try {
                        Properties prop = new Properties();
                        File file = new File("con.ini");
                        if(file.exists()){
                                file.createNewFile();
                        }
                       
                        FileInputStream fis = new FileInputStream(file);
                        prop.load(fis);
                       
                        int count = 0;
                        String value = prop.getProperty("count");
                        if(value!=null){
                                count = Integer.parseInt(value);
                        }
                                                      if(count>5){
                                System.out.println("使用次数已到,拿钱!");
                                return;
                        }
                        count++;
                        prop.setProperty("count", count+"");
                       
                        FileOutputStream fos = new FileOutputStream(file);
                       
                        prop.store(fos, "");
                       
                        fos.close();
                        fis.close();
                       
                } catch (IOException e) {
                        e.printStackTrace();
                }




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