读取properties的内容
来源:互联网 发布:先锋功放app软件 编辑:程序博客网 时间:2024/05/18 01:35
public static void main(String[] args) {
Properties props = new Properties();
try {
InputStream in = new BufferedInputStream(new FileInputStream(Utils.getTruePath()+
"/WEB-INF/classes/com/jerrys/jerseyrest/properties/systemconfig.properties"));
props.load(in);
Enumeration<?> en = props.propertyNames();
while (en.hasMoreElements()) {
String key = (String) en.nextElement();
String Property = props.getProperty(key);
System.out.println(key + "=" + Property);
}
} catch (Exception e) {
e.printStackTrace();
}
Properties props = new Properties();
try {
InputStream in = new BufferedInputStream(new FileInputStream(Utils.getTruePath()+
"/WEB-INF/classes/com/jerrys/jerseyrest/properties/systemconfig.properties"));
props.load(in);
Enumeration<?> en = props.propertyNames();
while (en.hasMoreElements()) {
String key = (String) en.nextElement();
String Property = props.getProperty(key);
System.out.println(key + "=" + Property);
}
} catch (Exception e) {
e.printStackTrace();
}
}
=============================================================
package com.jerrys.jerseyrest.utils;
import java.io.File;
public class Utils {
public static String notNull(String param) {
return param == null ? "" : param.trim();
}
public static String getTruePath() {
File f = new File(Utils.class.getResource("/").getPath());
String path = f.getPath();
path = notNull(path);
int index = path.indexOf("WEB-INF");
if (index > 0) {
return path.substring(0, index).replace("\\", "/");
} else {
return path.replace("\\", "/");
}
}
}
0 0
- 读取properties的内容
- 读取properties文件的内容配置数据库
- 读取properties文件的内容值
- 如何读取.properties配置文件的内容
- 读取properties文件内容
- 读取Properties配置文件内容
- properties文件读取内容
- java读取properties文件内容
- java 读取properties里面内容
- 读取properties文件中内容
- Java读取properties文件内容
- Java读取properties文件内容
- java读取properties文件内容
- Spring 读取properties文件内容
- Spring读取properties文件内容
- springMVC读取application.properties内容
- java读取properties文件内容
- java读取properties文件内容
- 《算法导论》10、中位数和顺序统计学(C++)
- 移动互联网终端的touch事件,touchstart, touchend, touchmove
- linux下db2执行脚本乱码问题
- pdf转换器绿色版软件
- jQuery验证控件jquery.validate.js使用说明+中文API
- 读取properties的内容
- Spring定时任务的几种实现
- PMC携手领军公司 亮相中国云计算大会
- 量子力学第十弹——外部电磁场
- 头像收起---ImageViewDraft
- 走过路过 不要错过
- 一行代码搞定所有屏幕适配AbViewUtil
- 用 ElementTree 在 Python 中解析 XML
- 网络各层功能职责——计算机网络