本帖最后由 杨增坤 于 2013-9-19 11:42 编辑
- import java.io.*;
- import java.util.*;
- public class PropertiesTest{
- public static void main(String[] args)throws IOException{
- File file=new File("count.txt");
- if(!file.exists())
- file.createNewFile();
- InputStream in=new FileInputStream(file);
- OutputStream out=new FileOutputStream(file);
- Properties pro=new Properties();
- pro.load(in);
-
- int count=0;
- String value=pro.getProperty("time");
- if(value!=null){
- count=Integer.parseInt(value);
- if(count>5){
- System.out.println("试用期已过,请购买");
- return;
- }
- }
- count++;
- pro.setProperty("time",count+"");
- pro.store(out,"");
- in.close();
- out.close();
- }
- }
复制代码 //我是想让程序运行达到一定次数后就不再能运行,请问这里那里错了?找了头天没找到,程序编译通过,但文件中的time总是1 |