Have a multi-line value in a properties fileTag(s): Language
You add a slash ("\") to continue the value on the next line.
Take the following properties file :
[props.properties]
prop1=first line of prop1 \ second line of prop1\ third line of prop1 prop2=first line of prop2 \n \ second line of prop2 \n \ third line of prop2
A program to read the properties file :
[Hello.java]
public class Hello { public static void main(String args[]) throws Exception{ Hello h = new Hello(); h.doit(); } public void doit() throws Exception{ // properties in the classpath java.util.Properties props = new java.util.Properties(); java.net.URL url = ClassLoader.getSystemResource("props.properties"); props.load(url.openStream()); System.out.println("prop1 :\n " + props.get("prop1")); System.out.println("prop2 :\n " + props.get("prop2")); } }
>java Hello prop1 : first line of prop1 second line of prop1third line of prop1 prop2 : first line of prop2 second line of prop2 third line of prop2
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com