private void notifyLines(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()) {
      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;
    }
  }
}

private void notifyLines ( 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 ( ) ) { 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 ; } } }
notify listeners for each complete line . note that in the case of stderr , the last line is saved .
