void (final String text, final Key outputType) { final StringBuilder entire; final StringBuilder lineRest; final boolean suppressed; if (ProcessOutputTypes.STDOUT == outputType) { entire = myStdout; lineRest = myStdoutLine; suppressed = isStdoutSuppressed(); } else if (ProcessOutputTypes.STDERR == outputType) { entire = myStderr; lineRest = myStderrLine; suppressed = isStderrSuppressed(); } else { return; } entire.append(text); if (suppressed && !LOG.isDebugEnabled()) { return; } int last = lineRest.length() > 0 ? lineRest.charAt(lineRest.length() - 1) : -1; int start = 0; for (int i = 0; i < text.length(); i++) { char ch = text.charAt(i); if (last == '\n' || last == '\r') { int savedPos; if ((ch == '\n' || ch == '\r') && ch != last) { savedPos = i - 1; } else { savedPos = i; } if (last != '\r' || savedPos != i) { String line; if (lineRest.length() == 0) { line = lineRest.append(text, start, savedPos).toString(); lineRest.setLength(0); } else { line = text.substring(start, savedPos); } if (!StringUtil.isEmptyOrSpaces(line)) { if (!suppressed) { LOG.info(line.trim()); } else { LOG.debug(line.trim()); } } } start = savedPos; } last = ch; } if (start != text.length()) { lineRest.append(text.substring(start)); } }