Solved

Java properties - slash inserted before colon when written out

Posted on 2003-10-31
6
1,655 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

809 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