yj10864
BlogJava
::
首頁
::
聯(lián)系
::
聚合
::
管理
8 Posts :: 1 Stories :: 9 Comments :: 0 Trackbacks
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
給我留言
查看公開留言
查看私人留言
我參與的團(tuán)隊(duì)
隨筆檔案
2010年1月 (1)
2009年12月 (2)
2009年11月 (1)
2009年10月 (2)
2009年9月 (2)
文章檔案
2009年10月 (1)
搜索
最新評論
1.?re: 23中設(shè)計(jì)模式-------輕松的比喻語言
不錯(cuò),讓我有了一定的理解。
--lexy
2.?re: 23中設(shè)計(jì)模式-------輕松的比喻語言
頂一下,牛!
--WIN
3.?re: 日期類的加減及java中所以日期類的操作算法大全
評論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--找個(gè)美女做老婆
4.?re: 日期類的加減及java中所以日期類的操作算法大全
評論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--找個(gè)美女做老婆
5.?re: 23中設(shè)計(jì)模式-------輕松的比喻語言
評論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
--找個(gè)美女做老婆
閱讀排行榜
1.?日期類的加減及java中所以日期類的操作算法大全(7623)
2.?23中設(shè)計(jì)模式-------輕松的比喻語言(3224)
3.?解析properties資源文件(645)
4.?Spring的字符過濾器的配置(580)
5.?tomcat關(guān)閉后重啟,SESSION 仍然有效的處理方法(352)
評論排行榜
1.?23中設(shè)計(jì)模式-------輕松的比喻語言(5)
2.?日期類的加減及java中所以日期類的操作算法大全(4)
3.?解析properties資源文件(0)
4.?使用 Java 生成 MD5 編碼 (0)
5.?tomcat關(guān)閉后重啟,SESSION 仍然有效的處理方法(0)
解析properties資源文件
1
import
java.io.FileInputStream;
2
import
java.io.FileOutputStream;
3
import
java.util.HashMap;
4
import
java.util.Iterator;
5
import
java.util.Properties;
6
7
8
/** */
/**
9
* 功能:解析資源文件
10
*
11
*/
12
public
class
PropertyUtil
{
13
14
private
Properties property
=
new
Properties();
15
private
String filepath
=
""
;
16
17
/** */
/**
18
* 解析資源文件的類的構(gòu)造函數(shù)
19
*
@param
path 文件索在的包,如:com.cn.myproperty.dbo.properties
20
*/
21
public
PropertyUtil(String path)
{
22
try
{
23
filepath
=
this
.getClass().getResource(
"
/
"
).getPath();
24
filepath
=
filepath
+
path;
25
26
27
property.load(
new
FileInputStream(filepath));
28
}
catch
(Exception e)
{
29
e.printStackTrace();
30
}
31
}
32
33
34
/** */
/**
35
* 返回資源文件的hashmap對象
36
*/
37
public
HashMap getElements()
{
38
HashMap map
=
new
HashMap ();
39
Iterator it
=
this
.property.keySet().iterator();
40
while
(it.hasNext())
{
41
String key
=
it.next().toString();
42
map.put(key, property.getProperty(key));
43
}
44
return
map;
45
}
46
47
48
//
返回資源文件里的值
49
public
String getvalue(String key)
{
50
if
(key
!=
null
)
51
return
this
.property.getProperty(key);
52
else
53
return
""
;
54
}
55
56
//
設(shè)置資源文件里的值
57
public
boolean
setvalue(String key,String value)
{
58
if
(key
!=
null
)
59
{
60
try
{
61
this
.property.setProperty(key,value);
62
this
.property.store(
new
FileOutputStream(filepath), filepath);
63
return
true
;
64
}
catch
(Exception ex)
{
65
System.out.println(
"
保存資源文件出錯(cuò)了
"
+
this
);
66
}
67
}
68
return
false
;
69
}
70
71
72
}
73
1
import
java.util.HashMap;
2
3
4
public
class
ConfigManager
{
5
private
static
HashMap map
=
null
;
6
static
{
7
if
(map
==
null
)
{
8
PropertyUtil propertyUtil
=
new
PropertyUtil(
"
property.properties
"
);
9
map
=
propertyUtil.getElements();
10
}
11
}
12
/** */
/**
13
* 得到SystemConfig資源文件中定義的值,如果未定義則返回空字符串,不是null
14
*
@param
key
15
*
@return
16
*/
17
public
static
String getValue(String key)
{
18
try
{
19
return
map.get(key).toString();
20
}
catch
(Exception ex)
{
21
System.out.println(ConfigManager.
class
+
"
>>> zi yuan wen jian mei you ding yi key suo dui ying de zhi
"
);
22
return
""
;
23
}
24
}
25
26
}
頁面使用:
1
ConfigManager.getValue(
******
)
posted on 2010-01-08 13:51
jerry yang
閱讀(645)
評論(0)
編輯
收藏
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
Copyright @ jerry yang
Powered by:
.Text
and
ASP.NET
Theme by:
.NET Monster
主站蜘蛛池模板:
黄页网站在线免费观看
|
免费不卡中文字幕在线
|
亚洲阿v天堂在线2017免费
|
亚洲成a人片在线观看中文!!!
|
亚洲日本中文字幕一区二区三区
|
99re热免费精品视频观看
|
久久99国产乱子伦精品免费
|
国产成人无码精品久久久免费
|
美女的胸又黄又www网站免费
|
国产成人精品日本亚洲专一区
|
亚洲国产一区二区三区青草影视
|
精品国产亚洲男女在线线电影
|
日本免费网站在线观看
|
日韩吃奶摸下AA片免费观看
|
91精品国产免费
|
日韩免费视频一区二区
|
成人免费av一区二区三区
|
免费一区二区无码视频在线播放
|
亚洲综合精品第一页
|
亚洲欧洲日产国码www
|
亚洲首页在线观看
|
无码专区—VA亚洲V天堂
|
亚洲av伊人久久综合密臀性色
|
久久精品国产精品亚洲人人
|
免费国产不卡午夜福在线
|
国产美女a做受大片免费
|
午夜时刻免费入口
|
全免费一级毛片在线播放
|
四虎免费在线观看
|
狠狠久久永久免费观看
|
韩国日本好看电影免费看
|
香蕉高清免费永久在线视频
|
国产精品成人无码免费
|
国产美女无遮挡免费网站
|
免费人成视频在线观看不卡
|
又爽又黄无遮挡高清免费视频
|
免费一级毛片在级播放
|
亚洲?v无码国产在丝袜线观看
|
亚洲成a人无码av波多野按摩
|
亚洲日韩在线观看
|
亚洲精品无码午夜福利中文字幕
|