【发布时间】:2026-01-07 23:40:01
【问题描述】:
出于各种原因,我正在使用 Apache 通用配置库来读取属性文件。我的代码如下。默认情况下,它会去除我想要避免的值前后的空格。有没有办法做到这一点?
CompositeConfiguration config = new CompositeConfiguration();
PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();
URL url = CommonConfig.class.getResource("samplePropertiesFile.properties");
Reader reader = new FileReader(new File(url.getFile()));
propertiesConfiguration.read(reader);
config.addConfiguration(propertiesConfiguration);
samplePropertiesFile.properties 的内容:
key=<space>value<space>
//前后的空格都必须保留。
【问题讨论】:
标签: java apache configuration