Solved

retaining comment in properties file

Posted on 2002-04-17
7
283 Views
Last Modified: 2008-02-26
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,
0
Comment
Question by:vibhav
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 9

Expert Comment

by:Venci75
ID: 6947531
.
0
 
LVL 3

Accepted Solution

by:
saxaboo earned 50 total points
ID: 6947539
AFAIK, there is no way to retain the header or comments. As a workaround, you can use a dummy property :

---- myfile.properties ----
#This is a comment
myvalue1=foo
myvalue2=bar
__MY_COMMENT__=This is a comment \
               that spans on 3 \
               lines

HTH,

-S
0
 
LVL 3

Expert Comment

by:shyamkumarreddy
ID: 6947540
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
0
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
LVL 2

Expert Comment

by:Andrey_Kulik
ID: 6947547
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
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6956322
Please click the link below to manage all your open and locked questions here needing your response and attention.
http://www.experts-exchange.com/jsp/memberProfile.jsp?mbr=vibhav&showQHistory=true
Moondancer - EE Moderator
0
 
LVL 9

Expert Comment

by:Venci75
ID: 7972300
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
0
 

Expert Comment

by:SpideyMod
ID: 8020381
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question