java LineSeparatorTesting...beforeTesting...afterc:\temp>java -Dline.separator="\n" LineSeparatorTesting...before\nTesting...after\nc:\temp>java -Dline.separator="\\n" LineSeparatorTesting...before\\nTesting...after\\nc:\temp>java -Dline.separator=\n LineSeparatorTesting...before\nTesting...after\n..." />

line.separator in Windows

I've been playing around with the line.separator option but I can't seem to get it to work using the command line switch.

System.out.println("Testing...before");

System.setProperty( "line.separator", "\n" );

System.out.println("Testing...after");

Works great if I run it as is. However if I try to use the command line switch -Dline.separator. As you can see below, when I try to use the JVM switch, whatever I've tried (so far) is used literally. Any suggestions?

c:\temp>java LineSeparator

Testing...before

Testing...after

c:\temp>java -Dline.separator="\n" LineSeparator

Testing...before\nTesting...after\n

c:\temp>java -Dline.separator="\\n" LineSeparator

Testing...before\\nTesting...after\\n

c:\temp>java -Dline.separator=\n LineSeparator

Testing...before\nTesting...after\n...

Read More »

By: coderanchjavageneral - Monday, 12 March

Related Posts