void (final Key outputType, final Iterator<String> lines, final StringBuilder lineBuilder) { if (!lines.hasNext()) return; if (lineBuilder.length() > 0) { lineBuilder.append(lines.next()); if (lines.hasNext()) { // line is complete final String line = lineBuilder.toString(); notifyLine(line, outputType); lineBuilder.setLength(0); } } while (true) { String line = null; if (lines.hasNext()) { line = lines.next(); } if (lines.hasNext()) { notifyLine(line, outputType); } else { if (line != null && line.length() > 0) { lineBuilder.append(line); } break; } } }