问题
I have attempted to use ini4j and inieditor to alter from java an ini configuration file. Unfortunately, both libraries rewrite the file putting spaces besides the = sign...
This breaks that C library it is attempting to configure.
#This is a sample of what I get:
[root]
role = administrator
last_login = 2003-05-16
#This is what I need:
[root]
role=administrator
last_login=2003-05-16
I saw that ini4j has something named FancyIniFormatter which apparently does just that but I was unable to find proper documentation on the usage... http://www.jarvana.com/jarvana/view/org/ini4j/ini4j/0.4.0/ini4j-0.4.0.jar!/org/ini4j/addon/FancyIniFormatter.class?classDetails=ok
I am hoping to do this natively from the library but I can always load up the file and perform a regex operation but if I can avoid it that would be great.
Thanks,
回答1:
The ini4j formater is based on Config. In this config the separator is set to char '=', but in the class IiniFormatter you have another declaration of separator as string " = ". This type is used when Config#isStrictOperator
is set to false.
Config config = new Config();
config.setStrictOperator(true);
IniFormmater formater = IniFormmater.newInstance(out, config);
来源:https://stackoverflow.com/questions/17859328/java-ini-without-spaces