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

© 付欢 中级黑马   /  2015-6-7 16:08  /  168 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

代码如下  运行后的文档统计次数一直是1次,求大牛帮忙看看
  1. package ReadWrite;

  2. import java.io.*;
  3. import java.util.*;

  4. public class RunCount
  5. {
  6.         public static void main(String[] args) throws IOException
  7.         {
  8.                 Properties prop = new Properties();
  9.                 File file = new File("count.ini");
  10.                 if(!file.exists())
  11.                         file.createNewFile();
  12.                
  13.                 FileInputStream fis = new FileInputStream(file);
  14.                 prop.load(fis);
  15.                
  16.                 int count = 0;
  17.                 String value = prop.getProperty("time");
  18.                
  19.                 if(value!=null)
  20.                         {
  21.                                 count = Integer.parseInt(value);
  22.                                 if(count>=5)
  23.                                        
  24.                                         System.out.println("您好,使用次数已到");
  25.                                         return;
  26.                                        
  27.                         }
  28.                 count++;
  29.                
  30.                 prop.setProperty("time",count+"");
  31.                
  32.                 FileOutputStream fos = new FileOutputStream(file);
  33.                 prop.store(fos, "");
  34.                
  35.                 fis.close();
  36.                 fos.close();
  37.                
  38.         }
  39. }






复制代码
您需要登录后才可以回帖 登录 | 加入黑马