########关于属性文件,知道的人进来###########

sxhv998 2003-12-12 04:46:09
怎样从.properties属性文件中存取设置参数?

给个完整的实例好吗?

还有个问题,就是如何把程序中的中文输出到文本

然后再从文本输入到程序中还是中文?

同样也是给个完整实例好吗?
...全文
42 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
seaman0916 2003-12-15
  • 打赏
  • 举报
回复
你看看CNJSP1.2 论坛的源代码,里面有很详尽的属性文件操作方法!

在www.cnjsp.com上可以找到,很好的开源项目!
sxhv998 2003-12-15
  • 打赏
  • 举报
回复
up
along603 2003-12-14
  • 打赏
  • 举报
回复
哦啦啦
redkey 2003-12-14
  • 打赏
  • 举报
回复
up
failinlove 2003-12-14
  • 打赏
  • 举报
回复
yaray 2003-12-14
  • 打赏
  • 举报
回复
如果info.properties文件放置在WEB-INF\classes目录下:
ResourceBundle.getBundle("info");

如果info.properties文件放置在WEB-INF\classes\com\yaray\config目录下:
ResourceBundle.getBundle("com.yaray.config.info");
ResourceBundle.getBundle("com/yaray/config/info");
任意一个均可
yaray 2003-12-14
  • 打赏
  • 举报
回复
按照 alphafish(alphafish) 提供的示例,补充一下:

info.properties文件放置在WEB-INF\classes目录下,内容有一行为:
TEST=abcdefg
#-----------
System.out.println("test:"+EnvPara.getString("TEST")); // 主键为TEST,输出“abcdefg”
sxhv998 2003-12-13
  • 打赏
  • 举报
回复
还有吗?
yangjuanli 2003-12-12
  • 打赏
  • 举报
回复
本想发例子,被 alphafish(alphafish) 抢了先。:)
alphafish 2003-12-12
  • 打赏
  • 举报
回复
以下代码是读取info.properties属性文件的参数。

测试环境jdk1.4

import java.util.ResourceBundle;

public class EnvPara
{
private static ResourceBundle resources = null;

public static void init()
{
if(resources == null)
{
resources = ResourceBundle.getBundle("info");
}
}

public static String getString(String sName)
{
String sResult = null;
try
{
init();
sResult = resources.getString(sName);
}
catch(Exception e)
{
e.printStackTrace();
sResult = null;
}
return sResult;
}

public static void main(String[] args)
{
System.out.println("test:"+EnvPara.getString("TEST"));
}
}
pigo 2003-12-12
  • 打赏
  • 举报
回复

搜索一下。

例子到处都是。

我就不帖自己写的了。

bluesmile979 2003-12-12
  • 打赏
  • 举报
回复
怎么都是要实例的,呵呵。
newman0708 2003-12-12
  • 打赏
  • 举报
回复
i remember a class is used to get the effect.

try by yourself.

and searth information from the net.

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧