properties文件的编写
1、properties文件是一个文本文件
2、properties文件的语法有两种,一种是注释,一种属性配置。
注 释:前面加上#号
属性配置:以“键=值”的方式书写一个属性的配置信息。
3、properties文件的一个属性配置信息值可以换行,但键不可以换行。值换行用“\”表示。
4、properties的属性配置键值前后的空格在解析时候会被忽略。
5、properties文件可以只有键而没有值。也可以仅有键和等号而没有值,但无论如何一个属性配置不能没有键。
#这是properties文件的注释,properties是以key=value存在的
key=value
PROPERTIES的解析
Properties properties
= new Properties();
String path
= 某个类名
.class.getClassLoader().getResource("").getPath();
InputStream inputStream
= new FileInputStream(path
+"properties配置文件的编译后的相对路径");
properties
.load(inputStream
);
String value
= properties
.getProperties("key");