简介
Properties(Java.util.Properties),主要用于读取Java的配置文件配置文件中很多变量是经常改变的。在Java中,其配置文件常为.properties文件,格式为文本文件,文件的内容的格式是“键=值”的格式,文本注释信息可以用"#"来注释。
继承关系
主要方法
- getProperty(String key) :获取主要键值
- load(InputStream inStream) :从输入流读取属性列表
- setProperty(String key, String value) :设置属性值
- store(OutputStream out, String comments) :写入属性列表
- clear() :清除键值对
实例
读取properties文件
InputStream in = getClass().getResourceAsStream("资源Name");
或者
InputStream in = new BufferedInputStream(new FileInputStream(filepath));
创建properties
步骤
- New
- Resource bundle
- 输入文件名,按确定
详情