本帖最后由 杨兴庭 于 2013-7-9 21:05 编辑
- import java.util.*;
- import java.io.*;
- 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,"");
- fos.close();
- fis.close();
- }
- }
复制代码 运行俩次就出现数字格式化异常;
|