code: private final static Thread stdOut(final Process p) {
          final byte[] empty = new byte[128];
          for (int b = 0; b < empty.length; b++) {
              empty[b] = (byte) 0;
          }
          Thread std = new Thread() {
              public void run() {
                  StringBuilder sb = new StringBuilder(1024);
                  byte[] buf = new byte[128];
                  BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
                  log.debug("Process output:");
                  try {
                      while (bis.read(buf) != -1) {
                          sb.append(new String(buf).trim());
                          // clear buffer
                          System.arraycopy(empty, 0, buf, 0, buf.length);
                      }
                      log.debug(sb.toString());
                      bis.close();
                  } catch (Exception e) {
                      log.error("{}", e);
                  }
              }
          };
          std.setDaemon(true);
          std.start();
          return std;
      }
docs: Special method for capture of StdOut.
  
  @return stdOut thread