Java属性文件规范 [英] Java properties file specs
本文介绍了Java属性文件规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
转义属性文件中的等号
.properties文件,我可以在第一个之后使用'='字符吗?
In a .properties file, can I use the character '=' after the first one?
像这样:
url=http://www.example.org/test=
它是否被允许,如果它确实存在,我在哪里可以知道它?
Is it allowed and where can I know that it is allowed if it indeed is?
到目前为止它似乎工作但是我不太确定它赢了以后再打破。
So far it seems to be working but I simply am not too sure it won't break later on.
推荐答案
你可以把反斜杠转义字符(\)
在 =
和之前:
。
You may put backslash escape character (\)
before =
and :
.
或者更好地使用以下代码打印出你的财产应该如何转义:
Or better use the following code that prints out how your property should be escaped:
Properties props = new Properties();
props.setProperty("url", "http://www.example.org/test=");
props.store(System.out, null);
输出:
#Wed Jan 12 14:30:39 GMT 2011
url=http\://www.example.org/test\=
另外,请查看 Java API信息
这篇关于Java属性文件规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文