Read .properties file
程序员文章站
2022-03-02 14:36:13
...
rules.properties :
ReadPro.java
rule1.id=callagent
rule1.name=Longest Waiting 1
rule1.type=custom
rule1.class=com.brekeke.ctiserver.acd.RuleCallAgent
rule1.description=Assign a call to an agent who has been waiting the longest.
rule1.param1.target=agent_id
rule1.param1.label=Timeout (sec)
rule1.param2.label=Queue size
rule1.param3.label=Next number
rule1.param4.label=Next number14
rule2.id=test
rule2.name=High Skill 1
rule2.type=custom
rule2.description=Find an agent who has the highest skill.
rule2.rule1.id=callagent
rule2.rule2.id=callagent
rule2.param1.target=rule1.param1
rule2.param1.label=Timeout (sec)
rule2.param2.target=rule2.param1
rule2.param2.label=Queue size
rule2.param3.label=Next number
rule2.param4.label=Next number24
ReadPro.java
public class ReadPro {
/**
* @author Bill Zhang
*/
public static void main(String[] args) {
File file = new File("src/pro/rules.properties");
if(file.exists()){
try {
FileInputStream fistream = new FileInputStream(file);
InputStream inStream = new BufferedInputStream(fistream);
Properties pro = new Properties();
try {
pro.load(inStream);
// System.out.println("=============Get Value By rule_id=====================");
// System.out.println(pro.get("rule1.id"));
System.out.println("===========================");
Enumeration<?> enu = pro.propertyNames();
while(enu.hasMoreElements()){
String key = enu.nextElement().toString().trim();
String[] strTemp = key.split("\\."); // "\\" is a convert symbol without it not work in the JDK 6.x
for(int i=0; i<strTemp.length; i++){
if(strTemp[i].equals("id"))
System.out.println(pro.get(key));
}
}
} catch (IOException e) {
System.out.println("+++++++++IOException++++++++");
e.printStackTrace();
}
} catch (FileNotFoundException e) {
System.out.println("++++++++FileNotFoundException+++++++++++");
e.printStackTrace();
}
}else{
System.out.println("File Not Found!");
}
}
}
上一篇: python版本切换
推荐阅读
-
使用yum命令报错File "/usr/bin/yum", line 30 except KeyboardInterrupt, e:
-
用file标签实现多图文件上传预览
-
mvc file控件无刷新异步上传操作源码
-
java中Properties文件加载和使用方法
-
php通过exif_read_data函数获取图片的exif信息
-
Codeigniter上传图片出现“You did not select a file to upload”错误解决办法
-
成功解决SyntaxError: Non-UTF-8 code starting with xc0 in file but no encoding declared; see http://p
-
Android local.properties 文件读取实例详解
-
Android WebView 不支持 H5 input type="file" 解决方法
-
jquery获取file表单选择文件的路径、名字、大小、类型