changing value inside property file at run time
<p>I wish to change a property value inside a property file.
I tried some ways, such as FileInputStream/FileOutputStream or Apache's library, but all of them alter the file structure.</p>

<p>The structure of my file is:</p>

<pre><code>#[Section 1]
prop1=value1
prop2=value2

#[Section 2]
prop2=value2
prop4=value4
</code></pre>

<p>After executing the code, the property changes, but "section" items disappear, and file only consists of a list of unordered properties.<br>
Is there a way to preserve the structure above?</p>

<p>I TRIED THESE WAYS: <a href="https://stackoverflow.com/questions/15337409/updating-property-value-in-properties-file-without-deleting-other-values">Updating property value in properties file without deleting other values</a></p>