Properties文件工具读取类
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class CommonPropertiesUtil {
private static CommonPropertiesUtil instance;
private CommonPropertiesUtil(){
}
public static synchronized CommonPropertiesUtil getInstance(){
if(instance == null){
instance = new CommonPropertiesUtil();
}
return instance;
}
/**
* 读取配置文件
* @return
*/
public Properties loadUploadProperty() {
Properties prop=new Properties();
InputStream is = null;
try {
is = this.getClass().getResourceAsStream("/uploadConfig.properties");
prop.load(is);
is.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
return prop;
}
}
Properties文件工具读取类的更多相关文章
- Property工具类,Properties文件工具类,PropertiesUtils工具类
Property工具类,Properties文件工具类,PropertiesUtils工具类 >>>>>>>>>>>>>& ...
- 关于properties文件的读取(Java/spring/springmvc/springboot)
一.Java读取properties文件 1.基于ClassLoder读取配置文件 注意:该方式只能读取类路径下的配置文件,有局限但是如果配置文件在类路径下比较方便. Properties prope ...
- Java读取properties文件工具类并解决控制台中文乱码
1.建立properts文件(error.message.properties) HTTP201= 请求成功并且服务器创建了新的资源 2.在spring-mvc.xml文件(applicationCo ...
- Properties文件工具类的使用--获取所有的键值、删除键、更新键等操作
有时候我们希望处理properties文件,properties文件是键值对的文件形式,我们可以借助Properties类操作. 工具类如下:(代码中日志采用了slf4j日志) package cn. ...
- Java Bean 获取properties文件的读取
实际的开发过程中,将一些配置属性从java代码中提取到properties文件中是个很好的选择,降低了代码的耦合度.下面介绍两种通过spring读取properties文件的方法,以ip地址配置为例. ...
- properties文件的读取
Demo //声明资源器类 Properties pro=new Properties(); //获取路径 URL url= PropertiesTest.class.getClassLoader() ...
- Android 对.properties文件的读取
/** * * @param filepath .properties文件的位置 */ public void checkFileExists(String filepath){ File file ...
- 读取Properties文件工具类
import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java ...
- 加载Properties文件工具类:LoadConfig
import javax.servlet.http.HttpServletRequest; import javax.ws.rs.GET; import javax.ws.rs.Path; impor ...
随机推荐
- 运用Pascal来破坏DLL的一个实例
运用Pascal来破坏DLL文件的一个实例 关于Pascal静态调用和动态的调用DLL的学习您可以看Delphi/Lazarus栏目. Uses Dos; {调用DOS库} Const Root='C ...
- appium+python的APP自动化(1)
写这个东西也是自己喜欢研究些自动化的东西,以下全是自己的经验所得,由于开源的软件对于各版本以及操作系统要求很高,会经常碰到一些不兼容的问题,这个都属于正常的,换版本就对了. 本人的环境搭建都是在win ...
- jmeter察看结果树响应数据中文乱码解决办法
1.到jmeter目录文件中bin文件夹下找到jmeter.properties文件,该文件为jmeter配置文件.使用编辑工具打开它. 2.找到 #sampleresult.default.e ...
- 易语言.开源(绝地求生多功能盒子)类似LOL盒子
下载地址:https://pan.baidu.com/s/1OXwCjGJODkcZVrCwVixu3Q 成品地址:https://pan.lanzou.com/i0rmdwj
- 【志银】NYOJ《题目860》又见01背包
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=860 方法一:不用滚动数组(方法二为用滚动数组,为方法一的简化) 动态规划分析:最少要拿总 ...
- wireshark简单使用
过滤表达式的规则 表达式规则 1. 协议过滤 比如TCP,只显示TCP协议. ip.src == 219.216.87.200 and ip.dst==219.216.87.254 2 ...
- linux configuration
sudo vi /etc/profile export JAVA_HOME=/usr/bin/jdk1.8.0_40export JRE_HOME=${JAVA_HOME}/jre export C ...
- Win10 Ubuntu18.04 编译安装 nignx
nginx 下载页 http://nginx.org/en/download.html wget http://nginx.org/download/nginx-1.14.0.tar.gz //安装依 ...
- Java性能监控之Java程序执行解析
大家好,最近接触javassist技术,研究过程中对Java程序执行过程进行了一系列探索,弄清楚了几个盲区(仅针对个人而言),现将经验与大家分享. 1.编码->.java 通常指写代码的过程,最 ...
- HDU - 2814 Visible Trees
题意: m*n(1<=m,n<=100000)的森林里,起始点在(1,1),某人从(0,0)点开始看,问能看到多少棵树. 题解: 求出1~x中的每个数与1~y的数中互质的数的总和.用素数筛 ...