views:

297

answers:

2

Hi guys,

How do i escape the equals ('=') sign in java properties file? i would like to put something like table.whereclause=where id=100 .

thanks.

Josh

+6  A: 

Default escape character in Java is '\'.
However, Java properties file has format key=value, it should be considering everything after the first equal as value.

Padmarag
+3  A: 

Moreover, Please refer to http://java.sun.com/javase/6/docs/api/java/util/Properties.html

In load() methods documentation it says

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,

\:\=

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.

Hope that helps.

Mohd Farid