Java Properties property value - message with leading white space

Sri picture Sri · Dec 5, 2013 · Viewed 7k times · Source

I have messages in properties file and reading these properties file using spring and spring message tag,

For example I have :

key.red=Red<br>
key.blue=  blue

blue message text coming as "blue" but not as " blue". The leading white spaces are taken out by spring:message tag.

how could i retain leading space ? I appreciate any help

Thanks,
Sri

Answer

dimoniy picture dimoniy · Dec 5, 2013

Try doing it like this:

key.blue=\u0020blue

You can use other unicode codes to escape characters as well. All per Java API doc. Quote:

...Characters that cannot be directly represented in this encoding can be written using Unicode escapes ....