Solved

Java properties - slash inserted before colon when written out

Posted on 2003-10-31
6
1,660 Views
Last Modified: 2008-01-16
I have a properties file that contains property/value pairs as follows:

propertya = :vala:valb:valc:

I simply read this into a properties object and write it back out to a new properties file. The new properties file would have written out this property as follows:

propertya = \:vala\:valb\:valc\:

Can anyone tell me why this happens?  and what I can do to prevent it from happening?   I am constrained to the current format of the initial properties file.

Thanks!
0
Comment
Question by:pauldoc
6 Comments
 
LVL 8

Expert Comment

by:_corey_
ID: 9659130
Could you post the snippet of writing to the file?
0
 

Author Comment

by:pauldoc
ID: 9659208
Actually,  I just looked closer at the javadoc for the properties class.  The store method has the following comment included:

"The key and value characters #, !, =, and : are written with a preceding slash to ensure that they are properly loaded. "

I guess there may not be a simple solution to this.

As for a code snippet - not much to it: I create a file output stream in one section of code and then pass that into the method where I write to the new file:

 properties.store(propOutStream,"Properties");
0
 

Accepted Solution

by:
n_sidhaye earned 75 total points
ID: 9663555
 Ok I got your point.you can replace : to - or other specific character which will not be special character after reading property you can replace the specific character by replace method.
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …

679 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