append properties file from java -
from java want read .properties file , if property present want re-set property again. lets .properties file has entry password=123 want check if password entry there replace 123 567. need keep content is. how that? please help
one solution can think of rightaway is
- load properties base .properties file.
- create new temp properties file , loop through entries original file write same in new file. in loop can change value of property while writing new file.
- after loop delete original file , rename temp file original file.
this approach has couple of limitations,
- do not use if concerned file last modified/created date, since creating whole new file here.
- if original file big, approach may cause memory problems.
hope helps!
Comments
Post a Comment