Common 常用模块

Date 日期处理

Reflection 反射

Input/Output 输入/输出

HTTP 请求

加密/解密

其他

ResourceHelper

ResourceHelper 用于定位类路径资源。不传目标类时,资源名相对于 classpath 根目录;传入目标类时,解析规则与 Class.getResource 一致。

String text = new ResourceHelper("config/application.properties").toString();
Properties properties = new ResourceHelper("config/application.properties").getProperties();

InputStream stream = new ResourceHelper("config.properties", MyService.class).getStream();

getStream() 可读取打包在 JAR 内的资源。getPath(boolean)list(Consumer<File>) 需要资源实际位于文件系统中,对 jar: URL 不一定可用。getJarDir() 在运行位置可确定时返回 JAR 所在目录。调用方需要自行关闭 getStream() 返回的流。