Why does System.getProperty ("line.seperator") return null?

As soon as the header asks why System.getProperty ("line.seperator") returns null.

From looking around, I understand that this should not be.

Running this code shows that it seems set when the delimited line is broken:

class Test { 
    public static void main( String[] args ) { 
        System.out.println(System.getProperties()); 
    } 
}

$ java Test 
{java.runtime.name=Java(TM) SE Runtime Environment, sun.boot.library.path=/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/i386, java.vm.version=19.1-b02, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=:, java.vm.name=Java HotSpot(TM) Server VM, file.encoding.pkg=sun.io, sun.java.launcher=SUN_STANDARD, user.country=GB, sun.os.patch.level=unknown, java.vm.specification.name=Java Virtual Machine Specification, user.dir=/home/niko, java.runtime.version=1.6.0_24-b07, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.endorsed.dirs=/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/endorsed, os.arch=i386, java.io.tmpdir=/tmp, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., os.name=Linux, (And so on...)

However, when I try to get this in code, I get null:

class Test{ 
    public static void main( String[] args ) { 
        System.out.println("This is not " + System.getProperty("line.seperator") + "Broken");
    } 
}

$ java Test
This is not nullBroken

I am using Ubuntu 10.10 and Java (build 1.6.0_24-b07).

thank

+5
source share
1 answer

You have an error line.separator.

+20
source

All Articles