I am using a java properties file to store some config information, on Object creation I am loading this information, then at certain points in the objects lifetime I want to overwrite the values in the properties file so that next time an object of this type is instantiated it is configured with current information. the setProperty method doesn’t seem to be doing this and when i use the store method it just appends a new (updared) copy of the file to the end of the original. Any ideas?
Thanks
setPropertycertainly won’t do this automatically (unless you use your own type which overrides it).storeshould be fine – but my guess is that you’re opening an output stream (or writer) for append rather than overwrite. Are you holding the output stream open all the time? Or perhaps you’re usingnew FileOutputStream(path, true)which will append? Without showing us any code, it’s hard to know what you’re doing wrong.As WizardOfOdds says, the preferences API may well be a better idea in the first place.