Reputation: 117
I have a properties file that i create manualy. I can to get the propert in the file by getProperty() function, but I can't change it! I try with setProperty() function, but the file isn't changed.
can u help me?
thanks!
zipi
Upvotes: 0
Views: 600
Reputation: 241
Did you try to call something like
prop.store(new FileOutputStream("config.properties"), null);
after calling prop.setProperty
method? Because it's the way you flush changes to file.
Without calling store changes are visible only in application memory.
Upvotes: 0
Reputation: 327
SetProperty() will only set the property during the runtime. It will not go and override your file property. It wont modify your file.
Upvotes: 0
Reputation: 121961
You need to write the properties file again using store()
(of which there are two variants). The setProperty()
method changes the value of property stored in memory, not the value of the property in the file the properties were loaded from.
For further reading see the Properties Tutorial.
Upvotes: 1