package cn.itcast.test;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class Test3 {
/**
* @param args
* 试用版软件,只可以适用10次,如果到达使用次数,提示购买正版,没有到达提示您还有几次机会
* @throws IOException
*/
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new FileReader("config.txt"));
String line = br.readLine();
br.close();
int times = Integer.parseInt(line);
if(times > 0) {
FileWriter fw = new FileWriter("config.txt");
fw.write(--times + "");
System.out.println("您的试用次数还有" + times + "次机会");
fw.close();
}else {
System.out.println("您的试用次数已到,请您购买正版");
}
}
}
|
|