0
我正在使用Apache公共配置库来读取属性文件出于各种原因。我的代码如下。默认情况下,它将删除值之前和之后的空格,这是我想要避免的。有没有办法做到这一点? samplePropertiesFile.properties的修改Apache CommonConfiguration以不修剪值
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);
内容:
key=<space>value<space>
//两个空间之前,必须保存好。
这是一个可能的解决办法。谢谢你。有没有办法保持属性文件完好,并通过代码更改实现解决方案? – user3366706
是的,当然有。你...... eehhhhh .... *更改代码!!?!?!!?*第1步:获取源代码。第2步:进行更改。第3步:编译并构建新的jar文件。第4步:在你的类路径中替换jar文件。 – Andreas
hmmmmm ...我期待着这样的事情 - https://commons.apache.org/proper/commons-configuration/userguide/howto_properties.html上的自定义属性阅读器和编写器部分,它是用于PropertiesConfiguration的,而不是CompositeConfiguration – user3366706