linlinyu
linlinyu
posts - 0, comments - 4, trackbacks - 0, articles - 15
導航
BlogJava
首頁
新隨筆
聯系
聚合
管理
<
2025年6月
>
日
一
二
三
四
五
六
25
26
27
28
29
30
31
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
1
2
3
4
5
留言簿
給我留言
查看公開留言
查看私人留言
隨筆檔案
2008年5月 (1)
文章分類
ejb(2)
flex(1)
hibernate(1)
html(1)
java(4)
javascript(1)
oracle(2)
roller
servlet(4)
spring
文章檔案
2008年10月 (1)
2008年6月 (1)
2008年5月 (2)
2008年1月 (1)
2007年12月 (4)
2007年11月 (6)
搜索
最新評論
1.?re: Flex 訪問 Ejb如此簡單
評論內容較長,點擊標題查看
--akan
2.?re: struts2 輸出xml格式內容
多謝了,挺有用的。
--lw
3.?re: firebug的使用
up,正需要這個。
try a try先,不知道有沒有javascript自動排版的功能。
--久城
4.?re: firebug的使用
不錯不錯
--解凍的魚
Property 文件讀取
Posted on 2007-11-25 10:56
linlin yu
閱讀(794)
評論(0)
編輯
收藏
所屬分類:
java
通用java 屬性文件讀取,將xxx.properties放在classpath中就可以運行了
package
com.soyoung.xxx.config;
import
java.io.InputStream;
import
java.util.Properties;
public
class
XXXConfig
{
private
static
String default_config
=
"
/xxx.properties
"
;
private
static
Properties mConfig;
static
{
mConfig
=
new
Properties();
try
{
Class config_class
=
Class.forName(XXXConfig.
class
.getName());
InputStream is
=
config_class.getResourceAsStream(default_config);
mConfig.load(is);
}
catch
(Exception e)
{
e.printStackTrace();
}
}
private
void
XXXConfig()
{
}
public
static
String getProperty(String key)
{
return
mConfig.getProperty(key);
}
public
static
String getProperty(String key, String defaultValue)
{
String value
=
mConfig.getProperty(key);
if
(value
==
null
)
return
defaultValue;
return
value;
}
public
static
boolean
getBooleanProperty(String name,
boolean
defaultValue)
{
String value
=
XXXConfig.getProperty(name);
if
(value
==
null
)
return
defaultValue;
return
(
new
Boolean(value)).booleanValue();
}
public
static
int
getIntProperty(String name)
{
return
getIntProperty(name,
0
);
}
public
static
int
getIntProperty(String name,
int
defaultValue)
{
String value
=
XXXConfig.getProperty(name);
if
(value
==
null
)
return
defaultValue;
return
(
new
Integer(value)).intValue();
}
public
static
void
main(String args[])
{
//
mConfig.setProperty("name", "jianglinyu");
System.out.println(XXXConfig.getProperty(
"
name
"
));
}
}
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
Flex 訪問 Ejb如此簡單
jboss ssl
struts2 輸出xml格式內容
Property 文件讀取
Powered by:
BlogJava
Copyright © linlin yu
主站蜘蛛池模板:
库尔勒市
|
抚宁县
|
保康县
|
山东省
|
黑龙江省
|
安吉县
|
怀集县
|
镇安县
|
阿拉善右旗
|
交城县
|
新宁县
|
深水埗区
|
京山县
|
德保县
|
聂荣县
|
巴南区
|
普安县
|
宁陵县
|
东兰县
|
泰安市
|
闸北区
|
花莲县
|
镇巴县
|
都匀市
|
宁国市
|
苗栗市
|
永新县
|
呼图壁县
|
新津县
|
清水河县
|
太白县
|
太仆寺旗
|
仲巴县
|
杭锦后旗
|
恩平市
|
兴文县
|
丹凤县
|
黄龙县
|
合阳县
|
金平
|
墨江
|