Map系列的Properties,实现程序运行次数计数

来源:互联网 发布:xp编程器官方网站 编辑:程序博客网 时间:2024/06/05 16:31
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();}}

软件运营商,,应该就是按照这种原理,实现对软件运行次数的控制,从而达到收费的目的的,我们知道原理后,,就可以 自己试试破解破解。  记录记录。。
原创粉丝点击