如何转义属性文件中的等号 [英] How to escape the equals sign in properties files

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

问题描述

如何在Java属性文件中转义等号( = )?我想在我的文件中放入以下内容:

How can I escape the equals sign (=) in Java property files? I would like to put something as the following in my file:

table.whereclause=where id=100


推荐答案

此外,请参阅 load(Reader reader) code>属性 javadoc上的类

Moreover, Please refer to load(Reader reader) method from Property class on javadoc

load(Reader reader)方法文档说它


该键包含所有字符
,从第一个$ b开始$ b非白色空格字符和
但不包括,第一个未转义的
'=' :'或空白字符
除了行终止符。所有
这些关键终止字符可以
包含在密钥中,通过使用前面的反斜杠
字符转义
;例如,

The key contains all of the characters in the line starting with the first non-white space character and up to, but not including, the first unescaped '=', ':', or white space character other than a line terminator. All of these key termination characters may be included in the key by escaping them with a preceding backslash character; for example,

\:\=

将是双字符键:=。
行终止符字符可以是
包括使用 \r \\\
escape
序列。
键之后的任何空格被跳过;如果密钥之后的第一个非白色
空格字符是'='
':',那么它被忽略,任何
之后的空白字符
也被跳过。所有剩余字符
在行上成为
关联元素字符串的一部分;如果
没有剩余的字符,
元素是空字符串。一旦
,原始字符序列
构成密钥,元素是
标识,转义处理是
执行如上所述。

would be the two-character key ":=". Line terminator characters can be included using \r and \n escape sequences. Any white space after the key is skipped; if the first non-white space character after the key is '=' or ':', then it is ignored and any white space characters after it are also skipped. All remaining characters on the line become part of the associated element string; if there are no remaining characters, the element is the empty string "". Once the raw character sequences constituting the key and element are identified, escape processing is performed as described above.

希望有所帮助。

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

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