I am using the Java API ini4j to parse ini files. My original .ini file has the following key-value format:
[section]
key=value
where no spaces are around the = character.
But after after using the ini.store() method to save changes into the file (where ini is the Ini object referencing my .ini file), the content in the .ini file becomes
[section]
key = value
where extra spaces are inserted around the = character. I am not sure if I am using the store() method correctly. Is there a way to get rid of the spaces?
---- Update ----
According to this answer, I have inserted the following lines in my code:
Config config = new Config();
config.setStrictOperator(true);
ini.setConfig(config);
The spaces are removed. But I have a new problem with the semicolons:
# before
[bashful]
weight = 45.7
height = 98.8
age = 67
homePage = http://snowwhite.tale/~bashful
homeDir = /home/bashful
# after
[bashful]
weight=45.7
height=98.8
age=67
homePage=http\\\://snowwhite.tale/~bashful
homeDir=/home/bashful
Finally resolved the problem. Post my own solution for future reference:
To get rid of spaces before and after =, need to use:
Make sure you are using Wini, not Ini. If you use Ini and config.setStrictOperator(true), the problem is that you will see extra back-slashes inserted before some special characters such as
:,", etc. Simple fix is to change Ini to Wini: