?
Solved

retaining comment in properties file

Posted on 2002-04-17
7
Medium Priority
?
284 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 200 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

762 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