读取proprtties工具类
来源:互联网 发布:程序员和产品经理关系 编辑:程序博客网 时间:2024/05/22 18:22
/*
* 两种方式
* InputStream inStream = this.getClass().getResourceAsStream("/xx.properties");//普通类好用
InputStream inStream = 类名.class.getResourceAsStream("/xxx.properties");//静态类好用
*/
/**
* 根据key取得类路径下properFilePath文件中的value值
* @param properFilePath pro文件的path
* @param key
* @return
*/
public static String getProKey(String properFilePath,String key){
String value="";
InputStream inStream =null;
try {
inStream = ReadPropertiesUtil.class.getResourceAsStream(properFilePath);
Properties prop = new Properties();
prop.load(inStream);
value=prop.getProperty(key);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(inStream!=null){
try {
inStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
//Object [] fmtargs = {""};//替换string中的{0}
//String content =MessageFormat.format (registerMessage, fmtargs);
return value;
}
* 两种方式
* InputStream inStream = this.getClass().getResourceAsStream("/xx.properties");//普通类好用
InputStream inStream = 类名.class.getResourceAsStream("/xxx.properties");//静态类好用
*/
/**
* 根据key取得类路径下properFilePath文件中的value值
* @param properFilePath pro文件的path
* @param key
* @return
*/
public static String getProKey(String properFilePath,String key){
String value="";
InputStream inStream =null;
try {
inStream = ReadPropertiesUtil.class.getResourceAsStream(properFilePath);
Properties prop = new Properties();
prop.load(inStream);
value=prop.getProperty(key);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(inStream!=null){
try {
inStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
//Object [] fmtargs = {""};//替换string中的{0}
//String content =MessageFormat.format (registerMessage, fmtargs);
return value;
}
阅读全文
0 0
- 读取proprtties工具类
- 读取配置文件工具类
- 读取Excel工具类
- 读取excel 工具类
- 配置文件读取工具类
- 读取配置文件工具类
- 图片读取工具类
- Properties 读取工具类
- 文件读取工具类
- 配置文件读取工具类
- 读取Properties工具类
- 配置文件读取工具类
- properties读取工具类设计
- properties读取工具类设计
- java读取配置文件工具类
- 读取网上图片工具类
- property配置文件读取工具类
- xml文件读取工具类
- BZOJ 3012: [Usaco2012 Dec]First! 字典树 拓扑排序
- 简洁方便的倒计时
- 哈夫曼+堆——UOJ#130/Luogu2168 [NOI2015]荷马史诗
- android简单的分享
- idea中如何运用码云托管项目
- 读取proprtties工具类
- SPI配置
- Serializable的序列化与反序列化
- Nginx windows常用命令
- java-cef编译过程
- 开发类专业术语
- ActivityToFragment
- python实现Prim算法求解加权连通图的最小生成树问题
- solr 全文检索服务器