zipi
zipi

Reputation: 117

property in properties file isn't changed

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

Answers (3)

pedjaradenkovic
pedjaradenkovic

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

Deepak
Deepak

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

hmjd
hmjd

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

Related Questions