zoukankan      html  css  js  c++  java
  • 读写properties文件方法

    按key读取properties文件中的value

        public static String readSystemConfig(String key){        
            Properties prop = new Properties();
            String value = null;
            try {
                InputStream inputStream = new FileInputStream(FilePath);
                prop.load(inputStream);
                value = prop.getProperty(key);
                inputStream.close();
            } catch (Exception e) {
                logger.error("读取配置文件出错",e);
            }
            return value.trim();        
        }

    按key写入properties文件内容

    public static void writePropertiesInfo(String key,String value) {
            Properties prop = new Properties();
            try {
                FileInputStream in = new FileInputStream(FilePath);
                prop.load(in);
                in.close();
                prop.setProperty(key, value);
                FileOutputStream out = new FileOutputStream(FilePath);
                prop.store(out, "Conmments");
                out.flush();
                out.close();
            } catch (Exception e) {
                logger.error("配置文件写入取错误" + e);
            }
        }
  • 相关阅读:
    XML组成部分
    XML语法
    XML概念
    HTTP协议:响应消息的数据格式---Response
    KM HDU 3718
    KM最大匹配 HDU 2255
    匈牙利算法
    母函数
    最长公共子序列 LCS
    hdu 4632 区间DP
  • 原文地址:https://www.cnblogs.com/fxust/p/7358935.html
Copyright © 2011-2022 走看看