Fixed behavior of readLine accepting *\n\n as a line, not two

This commit is contained in:
Seth Goings 2011-09-01 09:31:08 -06:00
parent 97e03b9f28
commit fb3a23f02d

View File

@ -42,13 +42,18 @@ public class BufferedReader extends Reader {
}
for (int i = position; i < limit; ++i) {
if (buffer[i] == '\n' || buffer[i] == '\r') {
if(buffer[i] == '\r') {
sb.append(buffer, position, i - position);
position = i + 1;
if(i+1 < limit && buffer[i+1] == '\n') {
position = i + 1;
return sb.toString();
}
return sb.toString();
} else if (buffer[i] == '\n') {
sb.append(buffer, position, i - position);
position = i + 1;
return sb.toString();
}
}
sb.append(buffer, position, limit-position);