private static Thread pipe()

in command.line/java/jetbrains/buildServer/core/runtime/RuntimeUtil.java [59:89]


  private static Thread pipe(final InputStream inStream, final IProgressMonitor monitor, final boolean error) {
    Thread reader = new Thread(new Runnable() {
      public void run() {
        try {
          int in;
          StringBuilder line = new StringBuilder();
          while ((in = inStream.read()) > -1) {// use
            if (monitor != null) {
              char letter = (char) in;
              if ('\n' == letter || '\r' == letter) {
                if (line.length() > 0) {
                  if (error) {
                    monitor.status(new ProgressStatus(ProgressStatus.ERROR, line.toString()));
                  } else {
                    monitor.status(new ProgressStatus(ProgressStatus.INFO, line.toString()));
                  }
                }
                line.setLength(0);
              } else {
                line.append(letter);
              }
            }
          }
        } catch (IOException e) {
          monitor.status(new ProgressStatus(ProgressStatus.ERROR, e.getMessage(), e));
        }
      }
    });
    reader.start();
    return reader;
  }