{:2_32:}
public class Demo3 {
public static void main(String[] args) throws IOException {
System.out.println("Welcom");
String str=System.getProperty("user.home");
File file=new File(str+"\\soft.propreties");
if(!file.exists()){
file.createNewFile();
}
Properties pro=new Properties();
pro.load(new FileInputStream(file));
String c=pro.getProperty("count");
int count=1;
if(c==null){
pro.setProperty("count", "1");
}else{
count=Integer.valueOf(c);
if(count>=3){
System.out.println("试用到期,请缴费");
System.exit(0);
}else{
count++;
pro.setProperty("count", String.valueOf(count));
}
}
System.out.println("使用"+pro.getProperty("count")+"次");
FileOutputStream fos=new FileOutputStream(file);
pro.store(fos, "soft");
fos.close();
}
} |
|