void (char[] buffer, StringBuilder line, int n) { if (myOptions.splitToLines()) { for (int i = 0; i < n; i++) { char c; if (i == 0 && myCarry) { c = '\r'; i--; myCarry = false; } else { c = buffer[i]; } if (c == '\r') { if (i + 1 == n) { myCarry = true; continue; } else if (buffer[i + 1] == '\n') { continue; } } if (c != '\n' || myOptions.sendIncompleteLines() || myOptions.withSeparators()) { line.append(c); } if (c == '\n') { sendText(line); } } if (line.length() > 0 && myOptions.sendIncompleteLines()) { sendText(line); } } else { onTextAvailable(new String(buffer, 0, n)); } }