Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

newline char in the java .properties file value

do I really need to resort ot raw unicode char escapes to embed newlines into my .properties file?

This lengthy discussion in documentation is cool but I somehow miss this point. Now trying to scan this bulk once again, but maybe someone knows?

Thanks, Anton


update

certain special characters, can be represented in keys and elements using escape sequences similar to those used for character and string literals

I was not that sure what those 'certain special characters' might be. The direct link from 1.4 javadocs did not lead to the proper section of the spec. But after looking up the proper paragraph this got quite clear for me.

like image 956
Anton Kraievyi Avatar asked Apr 23 '12 17:04

Anton Kraievyi


2 Answers

do I really need to resort ot raw unicode char escapes to embed newlines into my .properties file?

Nope. I'd expect \r or \n or \r\n to work just fine. You claim that the linked documentation misses the point, but it seems pretty relevant to me:

Characters not in Latin1, and certain special characters, can be represented in keys and elements using escape sequences similar to those used for character and string literals (see §3.3 and §3.10.6 of the Java Language Specification).

Section 3.10.6 is what you want, right?

like image 187
Jon Skeet Avatar answered Sep 26 '22 03:09

Jon Skeet


The line of the referenced 1.4 API Text that matters is:

The ASCII characters \, tab, form feed, newline, and carriage return are written as \\, \t, \f, \n, and \r, respectively.

like image 6
Angelo Fuchs Avatar answered Sep 26 '22 03:09

Angelo Fuchs