------- <a href="http://www.itheima.com" target="blank">android培訓</a>、<a href="http://www.itheima.com" target="blank">java培訓</a>、期待與您交流! ----------
package Twenty;
import java.io.*;
import java.util.*;
public class fourteen {
public static void main(String[] args)throws IOException {
Properties pop =new Properties();
File file=new File("count.ini");//對文件進行封裝可以判斷數據,而流不行。
if(!file.exists())
file.createNewFile();
FileInputStream fis=new
FileInputStream(file);
pop.load(fis);
int count=0;
String value=pop.getProperty("time");
if(value!=null)
count=Integer.parseInt(value);
if(count>=5)
{
System.out.println("試用期結束,請繳費");
return;
}
count++;
pop.setProperty("time",+ count+"");
FileOutputStream fos=new FileOutputStream(file);
pop.store(fos, "");
fos.close();
fis.close();
}
}
------- <a href="http://www.itheima.com" target="blank">android培訓</a>、<a href="http://www.itheima.com" target="blank">java培訓</a>、期待與您交流! ----------