Link to home
Start Free TrialLog in
Avatar of vibhav
vibhav

asked on

retaining comment in properties file

I'm loading properties file using properties api and saving it back with changes using same api...but if any comments were present in the file (preceded by #)..are getting lost if i save back.

Is their any way to retain the comments which were present in the file while saving back.

Thanks,
Avatar of Venci75
Venci75

.
ASKER CERTIFIED SOLUTION
Avatar of saxaboo
saxaboo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Which mode do u open the file.
I think u have used write mode to do it.
So u r loosing your comments.
Did u try to write it back to the file with comments.

Shyam
Default implementation of java.util.Properties ignores all comments. You could create wrapper that will replace all first '#' or '!' chars in property file with unique strings like:
#comment
comment206467=comment

before reading property file and will replace all this properties names with '#' or '!' symbols back when property file will be stored.

Best regards
Please click the link below to manage all your open and locked questions here needing your response and attention.
https://www.experts-exchange.com/jsp/memberProfile.jsp?mbr=vibhav&showQHistory=true
Moondancer - EE Moderator
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by: saxaboo
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange