import java.io.*;
import java.util.*;
class Test
{
public static void main(String args[])throws IOException
{
File file = new File("Test.txt");
if(!file.exists())
file.createNewFile();
BufferedReader br = new BufferedReader(new FileReader(file));
Properties pro = new Properties();
pro.load(br);
if((pro.getProperty("time"))==null)
pro.setProperty("time","1");
else if((pro.getProperty("time"))!=null)
{
String s = pro.getProperty("time");
int count = Integer.parseInt(s);
if(count>=5)
System.out.println("请注册后继续使用,交钱!!!");
else
{
count++;
System.out.println(count);
pro.setProperty("time",Integer.toString(count));
}
}
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
pro.store(bw,"");
br.close();
bw.close();
}
}
这样写代码没有问题,但是为什么我把输出流和输入流写在一起的时候就不符合需求了啊 ?
|
|