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

读写properties文件方法的更多相关文章

  1. Java读写.properties文件实例,解决中文乱码问题

    package com.lxk.propertyFileTest; import java.io.*; import java.util.Properties; /** * 读写properties文 ...

  2. 120prop-python3.7 读写.properties文件

    120prop-python3.7 读写.properties文件 转载 nature_ph 最后发布于2019-07-30 10:12:05 阅读数 229 收藏 发布于2019-07-30 10: ...

  3. java读写properties配置文件方法

    1.Properties类 Properties类表示了一个持久的属性集.Properties可保存在流中或从流中加载,属性列表中的key和value必须是字符串. 虽然Properties类继承了j ...

  4. WIN32读写INI文件方法

      在程序中经常要用到设置或者其他少量数据的存盘,以便程序在下一次执行的时候可以使用,比如说保存本次程序执行时窗口的位置.大小.一些用户设置的 数据等等,在 Dos 下编程的时候,我们一般自己产生一个 ...

  5. 读写properties文件

    1. 读properties文件 Properties props = new Properties(); try { InputStream in = new FileInputStream(&qu ...

  6. 25 读取jar包内log4j.properties文件方法

    //读取log4j日志配置文件 InputStream inputStream=ApplicationExecutor.class.getResourceAsStream("/log4j_h ...

  7. 用java读写properties文件的代码

    package com.LY; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.F ...

  8. C# 读写txt文件方法

    添加引用: using System.IO; 1.File类写入文本文件: private void btnTextWrite_Click(object sender, EventArgs e) { ...

  9. java读写Properties文件

                Java   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ...

随机推荐

  1. 数据类型比较:Long和BigDecimal

    1.基本类型: 基本类型可以用:">" "<" "==" 2.基本类型包装类:(对象类型) 2.1 Long 型: 要比较两个L ...

  2. influxDB概念

    一.基本概念 1)database--数据库,这个同传统数据库的数据库概念. 2)measurement--数据表,在InfluxDB中,measurement即为表的作用,同传统数据库中的table ...

  3. 常用代码块:创建httpclient 2

    HttpGet httpGet = new HttpGet(url);SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(ne ...

  4. Python里面如何拷贝一个对象?

    import copy lst=[1,2,3,4,[1,2]] # 复制列表lst,命名lst2 lst2=copy.copy(lst) print(f'这是lst3:{lst2}') # 深拷贝 l ...

  5. python cookbook第三版学习笔记二十一:利用装饰器强制函数上的类型检查

    在演示实际代码前,先说明我们的目标:能对函数参数类型进行断言,类似下面这样: @typeassert(int, int) ... def add(x, y): ...     return x + y ...

  6. mongodb文档支持的数据类型

    版权声明:转载请标明来源. https://blog.csdn.net/u014285882/article/details/25510377 1. 存储类型 mongodb文档相似于json,但不是 ...

  7. Kafka配置参数说明

    配置文件目录:/usr/local/kafka/config配置文件server.propertis参数说明:broker.id=0每一个broker在集群中的唯一标识,要求是正数,当该服务器的IP地 ...

  8. Some day some time we will do

    Age has been reached the end of the beginning of the world,May be guilty in his seems to passing a l ...

  9. More about Parameter Passing in Python(Mainly about list)

    我之前写了一篇关于Python参数传递(http://www.cnblogs.com/lxw0109/p/python_parameter_passing.html)的博客, 写完之后,我发现我在使用 ...

  10. Eclipse部署项目的时候抛异常【Multiple Contexts have a path of "/cdcpm".】

    Eclipse部署项目的时候抛异常[Multiple Contexts have a path of "/cdcpm".]重新clean .删除server都不好使.查看一下tom ...