Read .properties file in java with new string characters in values

I defined a .properties file with properties like this

A=Hello World this is a dummy text B=Bye Bye World I am leaving to mars 

I can read it correctly after loading the resource from the input stream and displaying well.

Now I want to define these properties as follows

 A= Hello World this is a dummy text B= Bye Bye World I am leaving to mars 

However, it does not load it as expected

 A as Hello World 

and

 B as Bye Bye World. 

Do I need to independently determine the regular expression and read it and fill it on the map.

Or is there a default method available in Properties.java ?

+4
source share
1 answer

You need to add \n and then end the line with the "continue" character: \

  A = Hello World \ n \
 this is a \ n \
 dummy text

Note that when loading a property file, leading spaces are truncated. So you need to add this to the end of the previous line if you need padding:

  A = Hello World \ n \
 this is a \ n \
 dummy text
+8
source

Source: https://habr.com/ru/post/1446676/


All Articles