glddydyzcw
将properties 做排列
import
java.util.Properties;
import
java.io.FileInputStream;
import
java.io.IOException;
import
java.util.Map;
import
java.util.TreeMap;
import
java.util.Iterator;
public
class
OrderedProperties
{
public
static
void
main(String[] args)
{
Properties prop
=
new
Properties();
try
{
prop.load(
new
FileInputStream(
"
test.properties
"
));
}
catch
(IOException ex)
{
System.out.println(
"
I/O Error!!! Probably \
"
test.properties\
"
not found.
"
);
}
Map orderedProp
=
new
TreeMap(prop);
Iterator itr
=
orderedProp.entrySet().iterator();
while
(itr.hasNext())
{
Map.Entry entry
=
(Map.Entry) itr.next();
System.out.println(entry.getKey()
+
"
=
"
+
entry.getValue());
}
}
}
发表于 2005-11-21 15:20
HelloWorld
阅读(110)
评论(0)
编辑
收藏
新用户注册
刷新评论列表
只有注册用户
登录
后才能发表评论。
网站导航:
博客园
IT新闻
Chat2DB
C++博客
博问
管理
<
2025年7月
>
日
一
二
三
四
五
六
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
导航
BlogJava
首页
发新文章
联系
聚合
管理
统计
随笔: 0
文章: 7
评论: 1
引用: 0
留言簿
给我留言
查看公开留言
查看私人留言
文章档案
2005年11月 (7)
搜索
最新评论
1. re: 常见Java面试题----编程题
好 漂亮 支持 多写点 谢谢
--路过