zoukankan      html  css  js  c++  java
  • java属性文件读取,属性修改

    /**
     * 属性文件读取
     * @author bestmata
     *
     */
    public class CommUtil {
    
        private static Logger logger=Logger.getLogger(CommUtil.class);
        
        
        private  Properties getAttionReplyPro(){
            try {
                InputStream in=CommUtil.class.getResourceAsStream("attionReply.properties");
                Properties p=new Properties();
                p.load(in);
                in.close();
                return p;
            } catch (Exception e) {
                logger.error(e);
            }
            return null;
            
        }
        
        //获取关注的标示
        public  String getAttionFlag(){
            Properties p=getAttionReplyPro();
            String attionFlag=p.getProperty("attionFlag");
            return attionFlag;
        }
        
        //设置attionFlag的值
        public  void setAttionFlag(String flag){
            try {
                Properties p=getAttionReplyPro();
                p.setProperty("attionFlag", flag);
                OutputStream out=new FileOutputStream(new File(CommUtil.class.getResource("attionReply.properties").toURI()));
                p.store(out, "");
                out.flush();
                out.close();
            } catch (Exception e) {
                logger.error(e);
            }
            
        }
        
        public static void main(String[] args) {
            CommUtil a=new CommUtil();
            a.setAttionFlag("fag4");
            System.out.println(a.getAttionFlag());
            
        }
    }
  • 相关阅读:
    反射 元类
    多态
    封装
    继承
    面向基础
    包 logging模块 hashlib模块 openpyxl 深浅拷贝
    常用模块
    re模块(正则表达式)
    模块 导入方式 软件开发目录规范
    第 3 章 镜像
  • 原文地址:https://www.cnblogs.com/huzi007/p/4150956.html
Copyright © 2011-2022 走看看