读写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);
}
}
读写properties文件方法的更多相关文章
- Java读写.properties文件实例,解决中文乱码问题
package com.lxk.propertyFileTest; import java.io.*; import java.util.Properties; /** * 读写properties文 ...
- 120prop-python3.7 读写.properties文件
120prop-python3.7 读写.properties文件 转载 nature_ph 最后发布于2019-07-30 10:12:05 阅读数 229 收藏 发布于2019-07-30 10: ...
- java读写properties配置文件方法
1.Properties类 Properties类表示了一个持久的属性集.Properties可保存在流中或从流中加载,属性列表中的key和value必须是字符串. 虽然Properties类继承了j ...
- WIN32读写INI文件方法
在程序中经常要用到设置或者其他少量数据的存盘,以便程序在下一次执行的时候可以使用,比如说保存本次程序执行时窗口的位置.大小.一些用户设置的 数据等等,在 Dos 下编程的时候,我们一般自己产生一个 ...
- 读写properties文件
1. 读properties文件 Properties props = new Properties(); try { InputStream in = new FileInputStream(&qu ...
- 25 读取jar包内log4j.properties文件方法
//读取log4j日志配置文件 InputStream inputStream=ApplicationExecutor.class.getResourceAsStream("/log4j_h ...
- 用java读写properties文件的代码
package com.LY; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.F ...
- C# 读写txt文件方法
添加引用: using System.IO; 1.File类写入文本文件: private void btnTextWrite_Click(object sender, EventArgs e) { ...
- 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 ...
随机推荐
- 时间格式化输出strtime
The format argument consists of one or more codes; as in printf, the formatting codes are preceded b ...
- VS的编译选项
转载下,对于VS的编译选项介绍蛮清楚的!! 1. 静态链接库.动态链接库.CRT.STL 我们要到一个函数,要么是需要该函数的源代码,要么是知道该函数的声明并有该函数的实现,这里的“实现”又分为静态链 ...
- Python:itertools模块(转)
原文:http://www.cnblogs.com/cython/articles/2169009.html itertools模块包含很多创建迭代器的函数,可以用各种方式对数据进行循环操作,此模块中 ...
- sql server监控图解
- (2)linux未使用eth0,未使用IPV4导致无法连接
首先ifconfig查看网络IP 看,我这里默认启用了2个网卡,一个是eth0,另一个是lo(基于loopback方式) 1.如果有eth0则做:界面修改 (1)输入命令setup,选择network ...
- 《Python 数据分析》笔记——数据的检索、加工与存储
数据的检索.加工与存储 1.利用Numpy和pandas对CSV文件进行写操作 对CSV文件进行写操作,numpy的savetxt()函数是与loadtxt()相对应的一个函数,他能以诸如CSV之类的 ...
- 剑指offer 面试38题
面试38题: 题:字符串的排列 题目:输入一个字符串,按字典序打印出该字符串中字符的所有排列.例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,ca ...
- Python 函数名作为字典值
Python中是没有switch的, 所以有时我们需要用switch的用法, 就只能通过if else来实现了. 但if else写起来比较冗长, 这时就可以使用Python中的dict来实现, 比s ...
- gitattributes手册
gitattributes(5) Manual Page 1.gitattributes是什么? gitattributes用于定义每个路径的属性. 其语法是:pattern attr1 attr2 ...
- Service degrade
服务降级:主要是针对非正常情况下的应急服务措施;比如电商平台,在针对618.双11等高峰情形下采用部分服务不出现或者延时出现的情形. 为什么是非正常情况下呢,比如我要出差,如果经常出差的话,要带的衣服 ...