If I run gradle task overwriting properties file it replaces : \: for example jdbc:postgresql: is getting replaced with jdbc\:postgresql\:

if I run gradle task to overwrite properties file it replaces : with : for example jdbc:postgresql: is getting replaced with jdbc:postgresql:

Should be : jdbc:postgresql://hostip/servicename value coming : jdbc:postgresql://hostip/servicename

below is the code

build.gradle

task loadfile << {
    Properties properties = new Properties()
    File file =new File("src/main/resources/serverConfig.properties");
    OutputStream myoutput
= new FileOutputStream(file);
properties.setProperty("postgresql.url","jdbc" + ":" + "postgresql" + ":" + "//hostip/servicename")
properties.store(myoutput, null);

question is why colon : is getting replaced with :

Because this is how Properties class works. It is escaped to make sure it can be loaded back properly. This is generic behavior as you can see in its documentation - http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#store(java.io.Writer,%20java.lang.String)