代码如下 运行后的文档统计次数一直是1次,求大牛帮忙看看
- package ReadWrite;
- import java.io.*;
- import java.util.*;
- public class RunCount
- {
- public static void main(String[] args) throws IOException
- {
- Properties prop = new Properties();
- File file = new File("count.ini");
- 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, "");
-
- fis.close();
- fos.close();
-
- }
- }
复制代码 |
|