本帖最后由 薆情媬証書 于 2013-10-20 19:37 编辑
这里的count为什么存文文件形式里面不自增了?
一直都是 times=1
就是毕老师讲的property中软件使用次数限制的那个!!- <p>import java.io.*;
- import java.util.*;</p><p>class d13_properties
- {
- public static void main(String[] args) throws IOException
- {
- Properties pro = new Properties();</p><p> File file = new File("d:\\info.txt");
- if(!file.exists())
- file.createNewFile();
-
- FileOutputStream fos = new FileOutputStream(file);
- FileInputStream fis = new FileInputStream(file);
-
- pro.load(fis);
-
- int count=0;
- String value = pro.getProperty("times");
- if(value!=null)
- {
- count = Integer.parseInt(value);
- if (count >= 5)
- {
- System.out.println("次数已到");
- }
- }
- count++;</p><p> pro.setProperty("times", String.valueOf(count));
- pro.store(fos, "");
- }
- }
- </p><p> </p>
复制代码 |