Properties文件工具读取类
2015-08-28 14:41
190 查看
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;
}
}
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;
}
}
相关文章推荐
- IntelliJ IDEA 14.x 与 Tomcat 集成,创建并运行Java Web项目
- linux 下安装配置apache + ph
- linux驱动初探之字符驱动
- 修改CentOS Linux的时间可以使用date指令
- nginx日志配置指令详解
- Ubuntu 配置 OpenGrok 环境
- 各个安卓版本 使用的 Linux Kernel Version
- How to stop uwsgi when no pidfile in config?
- Android模拟器访问本地tomcat下web应用
- Linux学习笔记-----Linux服务管理------RPM服务管理-----独立服务管理
- linux常用c函数(中文版)
- jdk centos
- nginx(四)初识nginx日志文件
- hadoop2企业级集群部署(DNS域名解析+NFS密钥共享+AWK批量复制)
- Kail Linux渗透测试教程之Recon-NG框架
- 【转载】linux awk命令详解
- java.lang.ClassNotFoundException: org.apache.axiom.om.OMNode
- Centos配置国内yum源
- Kinect开发教程:利用OpenNI进行手势识别
- 关于Linux下ifconfig -a eth0无法获取Ip的解决办法