- <p>import java.io.*;
- import java.util.*;
- class RunCount
- {
- public static void main(String[] args)
- {
- File conf=new File("count.ini");
- FileInputStream fis=null;
- FileOutputStream fos=null;
- try
- {
- if(!conf.exists())
- conf.createNewFile();
- fis=new FileInputStream(conf);</p><p>fos=new FileOutputStream(conf);
- Properties prop=new Properties();
- 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+"");
-
- prop.store(fos,"");
- }
- catch (IOException e)
- {
- throw new RuntimeException("文件创建失败!");
- }
- finally
- {
- try
- {
- if(fos!=null)
- fos.close();
- }
- catch (IOException e)
- {
- throw new RuntimeException("写出流关闭失败!");
- }
- try
- {
- if(fis!=null)
- fis.close();
- }
- catch (IOException e)
- {
- throw new RuntimeException("读取流关闭失败!");
- }
-
- }
- }
- }
- </p>
复制代码 为什么运行没效果?
|
|