读写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 ...
随机推荐
- 【转】.Net 程序集 签名工具sn.exe 密钥对SNK文件 最基本的用法
阐述签名工具这个概念之前,我先说说它不是什么: 1.它不是用于给程序集加密的工具,它与阻止Reflector或ILSpy对程序集进行反编译一毛钱关系都没有. 2.它很讨厌人们把它和加密联系在一起. 我 ...
- Using InfluxDB in Grafana,influxDB在grafana中使用
grafana带有功能丰富的数据源插件influxDB.支持丰富的查询编辑器.注释和templating(模版)查询. 增加数据源(Adding the data source) 点击顶部Grafan ...
- 小程序html 显示 图片处理
let arr = [] for (const v of r.data.data ){ // v.content = v.content.replace(/<img/g ,' <image ...
- 系统盘的消耗 谨慎的日志存储到系统盘+日志级别!! 569 error_log = /usr/local/php7/logs/php-error.log 26 error_log = /usr/local/php7/logs/fpm_error_log
案例: 系统盘一夜之间骤增近20G nginx + php-fpm cat /usr/local/nginx/conf/nginx.conf 查看对请求的处理 4个配置文件 /usr/local/n ...
- jQuery改变CSS使DIV显示
HTML: <div id="mazey" style="display:none;">www.mazey.net</div> jQue ...
- Security Report: Stop using relative path to import CSS files
Detecting and exploiting path-relative stylesheet import (PRSSI) vulnerabilities Early last year G ...
- Python里面如何拷贝一个对象?
import copy lst=[1,2,3,4,[1,2]] # 复制列表lst,命名lst2 lst2=copy.copy(lst) print(f'这是lst3:{lst2}') # 深拷贝 l ...
- 关于like %%的优化思路
测试数据:2亿行,被筛选出的数据,3KW多行. 众所周知 like %str%无法走索引,但是我们如果实在是有这种需求要达到like '%str%'的筛选目的,怎么优化好一些呢? 以下是我的一些思考: ...
- Symfony4 数据库连接
代码 https://github.com/liudianpeng/BlogMVC-Symfony4 在 .env 文件可以调整一下数据库连接信息 ###> doctrine/doctrine- ...
- Django的Model继承abstract,proxy,managed。。。
Django 中的 model 继承和 Python 中的类继承非常相似,只不过你要选择具体的实现方式:让父 model 拥有独立的数据库:还是让父 model 只包含基本的公共信息,而这些信息只能由 ...