package com.properties;
import java.io.*;
import java.util.*;
public class count {
public static void main(String[] args)throws IOException {
Count();
}
public static void Count() throws IOException{
File file=new File("E:\\tetx.propertites");//将文件封装将记录次数propertites对象存放进该文件
if(!file.exists()){
file.createNewFile();
}
FileInputStream fis=new FileInputStream(file);//将文件与Io流关联
Properties pro=new Properties();
pro.load(fis);//将io流与pro对相关联、
String value=pro.getProperty("time");
int count=0;//实现对程序运行次数的计数
if(value!=null){
count=Integer.parseInt(value);
if(count>=5){
System.out.println("已经超过了使用次数,禁止使用。。");
return;
}
}
count++;
pro.setProperty("time", count+"");
FileOutputStream fos=new FileOutputStream(file);
pro.store(fos, "");//关键步骤,实现内存数据与文件可以说是同步修改
pro.list(System.out);
fos.close();
fis.close();
}
}
软件运营商,,应该就是按照这种原理,实现对软件运行次数的控制,从而达到收费的目的的,我们知道原理后,,就可以 自己试试破解破解。 记录记录。。