+1  A: 

The problem is that the input will not be <0 when it reaches the line that returns null, so do:

while (leido.length() != 0) {
    ....
}
Nathaniel Flath
Sorry, I mistyped (!leido.equals(null)), I actually used while (leido != null)) like you said and got stuck reading. I want the reading to stop when a blank line enters
omgzor
Thanks, this solves all issues.
omgzor
+1  A: 

I am not really sure if I understand your problem correctly. If you merely want your program to stop reading from the console, you can "close" the console by hitting Ctrl+D (Linux) or Ctrl+Z (Windows). This causes System.in.read() to return -1, so that ReadLn method would return null.

Check for null as Nathaniel suggested.

Edit: (based on your comment)

The problem is with this condition in the ReadLn method

if ((input < 0) && (length == 0)) return null;

If you enter a blank line, length will be 0, input will be > 0 though (whatever your system uses to denote a newline). If you change it to

if ((input < 0) || (length == 0)) return null;

the method will return null if either the input stream is closed or a blank line is entered.strong text

rodion
I want the program to stop reading from console when it gets a blank line. I'm using Netbeans' console on Windows, but I don't think hitting ctrl+z would work here.
omgzor
thanks, this does stop the reading. Thing is, it takes two blank lines to produce the output. How can I change it just to take one?
omgzor
+1  A: 

Instead of !leido.equals(" "), simply use !leido.equals(""). The former terminates when a line containing only a space is entered, the latter when a blank line is entered.

kdt
A: 

I dont understand your problem much, but just a suggest from my side will be that use your condition in this way

while(!" ".equals(leido)){  
//instead of   
while (!leido.equals(" ")){

why ?, because your code will throw a Exception if your variable contains null, and the condition which i mentioned will never do that :P