get the next line from the input
int ch = -1;
if (pushed != -2) {
ch = pushed;
pushed = -2;
} else {
ch = in.read();
}
if (ch == -1) {
return null;
}
lineEnd = "";
StringBuffer line = new StringBuffer();
int state = 0;
while (ch != -1) {
if (state == 0) {
if (ch == '\r") {
state = 1;
} else if (ch == '\n") {
lineEnd = "\n";
break;
} else {
line.append((char) ch);
}
} else {
state = 0;
if (ch == '\n") {
lineEnd = "\r\n";
} else {
pushed = ch;
lineEnd = "\r";
}
break;
}
ch = in.read();
}
if (ch == -1 && state == 1) {
lineEnd = "\r";
}
if (includeDelims) {
line.append(lineEnd);
}
return line.toString();