Warm tip: This article is reproduced from stackoverflow.com, please click
java properties configuration

Java: possible to line break in a properties file?

发布于 2020-03-27 10:15:55

Is it possible to continue a long string on the next line in a Java properties file?

e.g., somehow

myStr=Hello
      World

and when I get getProperty("myStr") it will return with "Hello World"?

Questioner
Pete
Viewed
160
John Flatness 2013-01-30 07:46

A backslash at the end of a line lets you break across multiple lines, and whitespace that starts a line is ignored:

myStr = Hello \
        World

The Java docs put it this way:

A logical line holds all the data of a key-element pair, which may be spread out across several adjacent natural lines by escaping the line terminator sequence with a backslash character \.