StringBuffer sb = new StringBuffer("");
while (true) {
int c = this.read();
if (c == -1) { // end of stream
return null;
}
else if (c == '\n") {
if (lookingForLineFeed) {
lookingForLineFeed = false;
continue;
}
else {
return sb.toString();
}
}
else if (c == '\r") {
lookingForLineFeed = true;
return sb.toString();
}
else {
lookingForLineFeed = false;
sb.append((char) c);
}
}