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

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();
	
		
	}
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值