本帖最后由 奋发吧小白 于 2014-9-17 21:54 编辑
package copydirectory;
import java.util.*;
import java.io.*;
public class RunTime {
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
Properties porp = new Properties();
File file = new File("D:\\info.txt");
if(!file.exists())
{
file.createNewFile();
}
FileInputStream fis = new FileInputStream(file);
porp.load(fis);
int count = 0;
String value = porp.getProperty("time");
if(value!=null)
{
count = Integer.parseInt(value);
if(count>6)
{
System.out.println("您使用次数已到,请激活");
return;
}
}
count++;
porp.setProperty("time", count+"");//setProperty() 方法两个参数 都是 String 类型,count+""和“count”这两种写法 不都是String类型吗? //为什么“count”这样写 程序就不能正常运行?
FileOutputStream fos = new FileOutputStream(file);
porp.store(fos, "");
fis.close();
fos.close();
}
}
|
|