(关于java的)myeclipse中properties文件的创建,急急急!

来源:百度知道 编辑:UC知道 时间:2024/06/07 21:59:32
myeclipse中properties文件怎么创建(详细步骤),他跟xml文件到底有什么区别和联系(详细),谢谢

XML档案的阶层格式适用于于组态设定,也因此许多的开源专案都将XML作为预设的组态定义方式,但通常也会提供非XML定义档的方式,像属性档案. properties,Spring也可以让您使用属性档案定义Bean,例如定义一个beans-config.properties:
beans-config.properties

helloBean.class=onlyfun.caterpillar.HelloBeanhelloBean.helloWord=Welcome!

下个properties.jar的包就可以在eclipse中创建.properties文件了
和一般的资源文件创建一样
都是KEY=VALUE的形式
key都是英文
value是中文
只不过*.properties文件不能显示中文
所以要经过java自带的工具进行编码处理
操作如下
1.在命令行下转到你要转换文件的目录
2.要输入的命令格式如下:
native2assii [-encoding Encoding] [inputfile [outputfile]]
例子:
native2assii -encoding gb2312 application_temp.properties application_zh_CN.properties

//properties文件实际是一个一个的键/值对儿
public class Test extends Properties{ //继承Properties类
public Test(){//重写构造函数
InputStream is= getClass().getResourceAsStream("aaa.properties");
//创建一个流来读取文件名是aaa.propert,
load(is); 加载流;
}

public static void main(String[] args){
System.out.p