• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1457
  • Last Modified:

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


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


pls help to write waht i want to the file
  • 4
2 Solutions
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. :(
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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

import java.util.*;

public class Z2 {
  public static void main(String[] args) throws Exception {
    Properties p = new Properties();
    p.setProperty("jdbcurl", "jdbc:mysql://");
    p.store(new 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
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.
Glad to help
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now