Solved

Java properties - slash inserted before colon when written out

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoreUp challenge 14 48
strCopies  challenge 17 73
wordmultiple challenge 12 89
Installed softare without GUID 6 54
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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 …

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now