How to process the Properties file!
来源:互联网 发布:怎么在淘宝卖游戏账号 编辑:程序博客网 时间:2024/05/05 05:42
Quote From:http://blog.csdn.net/daryl715/archive/2007/09/26/1802204.aspx
Properties pro = new Properties();
try {
InputStream inStr = ClassLoader.getSystemResourceAsStream("wahaha.properties");
pro.load(inStr);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//propertyNames(),返回属性列表中所有键的枚举
Enumeration enu2=pro.propertyNames();
while(enu2.hasMoreElements()){
String key = (String)enu2.nextElement();
System.out.println(key);
}
//Properties 继承于 Hashtable,elements()是Hashtable的方法,返回哈希表中的值的枚举。
Enumeration enu=pro.elements();
while(enu.hasMoreElements()){
String key = (String)enu.nextElement();
System.out.println(key);
}
//Properties 继承于 Hashtable,entrySet()是Hashtable的方法,
//返回此 Hashtable 中所包含的键的 Set 视图。此 collection 中每个元素都是一个 Map.Entry
Iterator it=pro.entrySet().iterator();
while(it.hasNext()){
Map.Entry entry=(Map.Entry)it.next();
Object key = entry.getKey();
Object value = entry.getValue();
System.out.println(key +":"+value);
}
假设wahaha.properties中内容为:
------------------------------
name1=xxxx
name2=yyyyy
name3=zzzzzzz
------------------------------
上面的代码将会输出:
--------------------------
name1
name2
name3
xxxx
yyyyy
zzzzzzz
name1:xxxx
name2:yyyyy
name3:zzzzzzz
---------------------------------
- How to process the Properties file!
- How do I get multiple process to log to the same file?
- How To Trace The Remote File Server (RFS) Process In Physical Standby Database (Doc ID 1481125.1)
- How to access a value defined in the application.properties file in Spring Boot ( Externalized Conf)
- how to let the process kill itself?
- how to use Properties and File to Save Data
- How to open the .bin file
- How to remove ^M in the file
- How to extract the file *.tar.bz2?
- TFS2010-How to unlocking the file
- HOW TO Use the GCC specs file
- How to set the Collation properties of the database
- How to measure the process memory (basic concept)
- How to view the W3WP process by c#?
- How to know the port which process is using
- how to check which process occupied the port
- Java How to get the PID from a process?
- how to process postbacks
- 单点登录系统(SSO)详细设计说明书(上篇)
- 调用系统命令实现删除文件的操作,java调用系统命令实现删除文件的操作
- MFC 重写Button类
- 开放源代码搜索引擎
- Flex builder3与eclipse整合
- How to process the Properties file!
- MySQL数据库的安装和操作(无安装)
- 利用java操作Excel文件
- ORACLE SQL性能优化系列(七)
- 嵌入式系统调试诊断方法
- 三级连动的下拉框(数据库版)--吐血推荐
- python 访问 sqlite 数据库
- 使用定时器实现Js的延期执行或重复执行setTimeout,setInterval
- 心静是一种境界