writing : (colon) character problem

Posted on 2006-04-27
Last Modified: 2012-05-05
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


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


pls help to write waht i want to the file
Question by:Econify
    LVL 14

    Expert Comment

    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.

    Author Comment


    hi mr unaware
    as ur name suggests
    i didn't ask to explain me my problem.if possible please propose a solution. :(
    LVL 11

    Assisted Solution

    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
    LVL 14

    Accepted Solution

    import java.util.*;

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

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

    Expert Comment

    There is no other effective way to escape special characters, unless You do it manually.

    P.S. the code is missing an import of* package.
    LVL 14

    Expert Comment

    Glad to help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    The viewer will learn how to implement Singleton Design Pattern in Java.

    761 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

    9 Experts available now in Live!

    Get 1:1 Help Now