code: public static void redirectStreams(Process process, OutputStream output, OutputStream error){
          if(output!=null)
              new Thread(new IOPump(process.getInputStream(), output, false, false).asRunnable()).start();
          if(error!=null)
              new Thread(new IOPump(process.getErrorStream(), error, false, false).asRunnable()).start();
      }
docs: Redirects given process's input and error streams to the specified streams.
  the streams specified are not closed automatically. The streams passed
  can be null, if you don't want to redirect them.
  
  @param process   process whose streams to be redirected
  @param output    outputStream to which process's inputStream is redirected.<br>
  null if you don't want to redirect.
  @param error     outputStream to which process's errorStream is redirected.<br>
  null if you don't want to redirect.