关于Properties的制作配置文件(当一个app已经5次被打开我们就收费)

package test;
 
 
import java.io.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.zip.InflaterInputStream;
 
import javax.annotation.processing.FilerException;
import javax.management.RuntimeErrorException;

import privateclass.Filterby_Name;
import privateclass.Filterby_hidden;
import privateclass.Filterby_java;
import privateclass.MyBufferedReader;
 
public class Main {
 
    private static final String space_operator = " ";
    private static final double pi = Math.PI;
    private static final String LINE_SEPARATOR = System.getProperty("line.separator");
    public static void main(String[] args) throws Exception {
 
    	countapp();
       
    }
	public static void countapp() throws IOException {
		File file = new File("count.properties");
		if(!file.exists())file.createNewFile();
		FileReader fr = new FileReader(file);
		int count = 0;
		Properties prop = new Properties();
		prop.load(fr);
		
		String value = prop.getProperty("time");
		if(value != null)
		{
			count = Integer.valueOf(value);
			if(count >= 5)
			{
				throw new RuntimeException("给钱吧臭弟弟,不然别用哼");
			}
		}
		count ++;
		prop.setProperty("time", count + "");
		FileWriter fw = new FileWriter(file);
		prop.store(fw, "jishuqi");
	}
}

  

关于Properties的制作配置文件(当一个app已经5次被打开我们就收费)

上一篇:flutter学习笔记(2)android编译,以及如何加快首次编译时间。


下一篇:解决ios下2019-01-03T00:18:21.000+0000格式转化显示null、undefined大坑