保存到属性文件转义: [英] Saving to properties file escapes :

查看:101
本文介绍了保存到属性文件转义:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我存储属性文件时,有没有人知道为什么冒号会被转义?

Does anyone know why the colons are getting escaped when I store the properties file?

我这样做:

Properties prop = new Properties();


// Set the properties value.

prop.setProperty("url","http://localhost:7101/test/home");

并使用以下方式存储:

prop.store(new FileOutputStream(propFile), null);

它正在运行,但由于某种原因输出冒号逃脱:

It's working but the output has colons escaped for some reason:

url=http\://localhost\:7101/test/home

任何人都知道修复?

推荐答案

在属性文件中,这两者都是合法的:

In properties files, both of these are legit:

key1 = value
key2: value

因此,=和:必须被转义。

So both = and : must be escaped.

现在,如果你用属性读回来了,那就是没问题。否则,您将不得不编写自定义代码

Now, if you read the thing back with Properties, it's no problem. Otherwise, you'll have to write custom code

这篇关于保存到属性文件转义:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆