writing : (colon) character problem

hi experts

i am writhng a property value to a properties file
using java propety object.
the value that i am trying to write is

jdbcurl=jdbc:mysql://192.168.0.60:3306/kessler

but the output in the file contains / befor every (:) colon like this

jdbcurl=jdbc/:mysql/://192.168.0.60/:3306/kessler

pls help to write waht i want to the file
EconifyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StillUnAwareCommented:
If it is there, then it should stay there. In other words if You used to write properties using Properties class, then it is assumed You are going to read the values back using the Properties file. This is the standard format for colon when writing special characters and if You will use Properties object to read the values back the string will stay unchanged.
EconifyAuthor Commented:

hi mr unaware
as ur name suggests
i didn't ask to explain me my problem.if possible please propose a solution. :(
fargoCommented:
you need to use Properties for reading and writing (both). The special characters will be taken care of automatically. Use the below link for more information
http://javaalmanac.com/egs/java.util/Props.html
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

StillUnAwareCommented:
import java.util.*;

public class Z2 {
  public static void main(String[] args) throws Exception {
    Properties p = new Properties();
    p.setProperty("jdbcurl", "jdbc:mysql://192.168.0.60:3306/kessler");
    p.store(new FileOutputStream("props.txt"), null);
    /*here You get the file output like this:
   
    #Thu Apr 27 12:08:27 EEST 2006
    jdbcurl=jdbc\:mysql\://192.168.0.60\:3306/kessler

    all special characters (including colon) are escaped using backslash (\).
    This is the default behaviour.*/
    p = new Properties();
    p.load(new FileInputStream("props.txt"));
    System.out.println(p.getProperty("jdbcurl"));
    //here You get the same string which was written to the file
  }
}

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
StillUnAwareCommented:
There is no other effective way to escape special characters, unless You do it manually.

P.S. the code is missing an import of java.io.* package.
StillUnAwareCommented:
Glad to help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.