• 关于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");
    	}
    }
    

      

  • 相关阅读:
    winston写日志(译)
    H5打字机特效
    Flutter 手指放大 平移 旋转 Widget
    51nod1432【贪心】
    死锁的例子
    C# SpinLock用法。
    鼓音效
    rm-rf
    cdoj 1334 郭大侠与Rabi-Ribi Label:贪心+数据结构
    1092 回文字符串(51nod)
  • 原文地址:https://www.cnblogs.com/WINDZLY/p/11823260.html
Copyright © 2020-2023  润新知