英文:
How to create properties without white spaces between separator using org.apache.commons.configuration.PropertiesConfiguration?
问题
Sure, here's the translated version:
需要使用org.apache.commons.configuration.PropertiesConfiguration编写一个属性文件,其格式应类似于variablename=variablevalue,在分隔符之间不应有空格。是否有办法使用apache commons-configuration实现这一点?
我的当前实现:
PropertiesConfiguration conf = new PropertiesConfiguration("test.properties");
conf.setProperty("key1", "value1");
conf.save();
结果:
key1 = value1
期望结果:
key1=value1
英文:
Need to write a properties file using org.apache.commons.configuration.PropertiesConfiguration and it should have a format like variablename=variablevalue without having whitespaces between the separator. Is there a way to achieve that using apache commons-configuration?
My current implementation :
PropertiesConfiguration conf = new PropertiesConfiguration("test.properties");
conf.setProperty("key1","value1");
conf.save();
Result :
key1 = value1
Expected Result :
key1=value1
答案1
得分: 2
Docs are here: link
Untested but I imagine this does it:
conf.getLayout().setGlobalSeparator(""=");
英文:
Docs are here: https://commons.apache.org/proper/commons-configuration/userguide_v1.10/howto_properties.html
Untested but I imagine this does it:
conf.getLayout().setGlobalSeparator("=");
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论