diff --git a/classpath/java/io/BufferedReader.java b/classpath/java/io/BufferedReader.java index 6d67e71c29..3db923c5e9 100644 --- a/classpath/java/io/BufferedReader.java +++ b/classpath/java/io/BufferedReader.java @@ -38,16 +38,18 @@ public class BufferedReader extends Reader { } if (position >= limit) { - return sb.toString(); + return sb.length() == 0 ? null : sb.toString(); } for (int i = position; i < limit; ++i) { if (buffer[i] == '\n') { - sb.append(buffer, position, i); + sb.append(buffer, position, i - position); position = i + 1; return sb.toString(); } } + sb.append(buffer, position, limit-position); + position = limit; } }