Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

spelling

Exactly as the title asks, why is System.getProperty("line.seperator") returning null.

From looking around I gather that it shouldn't.

Running this code shows that it seems to be set as the line with the separator 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 trying 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).

Thanks

like image 817
nikomax Avatar asked Apr 11 '11 13:04

nikomax


1 Answers

You've misspelt line.separator.

like image 80
NPE Avatar answered Sep 18 '22 12:09

NPE