Solved

Java properties - slash inserted before colon when written out

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
White board coding practice 3 88
Scripting vs. Programming languages 25 166
Tviruailstringtree sort multi columns on header click 1 63
Selenium docs api java index 3 15
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about problems I had with the new location API and permissions in Marshmallow
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 fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

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