是 java 实现的 property 框架。

特点

  • 优雅地进行属性文件的读取和更新

  • 写入属性文件后属性不乱序

  • 灵活定义编码信息

  • 使用 OO 的方式操作 property 文件

  • 支持多级对象引用

变更日志

ChangeLog

快速开始

环境依赖

Maven 3.x

Jdk 1.7+

Maven 引入依赖

<dependency>     <groupId>com.github.houbb</groupId>     <artifactId>property</artifactId>     <version>0.0.4</version> </dependency>

入门案例

读取属性

PropertyBs.getInstance("read.properties").get("hello");

read.properties 为文件路径,hello 为存在的属性值名称。

读取属性指定默认值

final String value = PropertyBs.getInstance("read.properties")                 .getOrDefault("hello2", "default");

read.properties 为文件路径,hello2 为不存在的属性值名称,default 为属性不存在时返回的默认值。

设置属性

PropertyBs.getInstance("writeAndFlush.properties").setAndFlush("hello", "world-set");

writeAndFlush.properties 为文件路径,hello 为需要设置的属性信息。

引导类方法概览

序号 方法 说明
1 getInstance(propertyPath) 获取指定属性文件路径的引导类实例
2