public static Process pipeTo ( final Process left , final Process right ) throws IOException { new Thread ( new Runnable ( ) { public void run ( ) { InputStream in = new BufferedInputStream ( getIn ( left ) ) ; OutputStream out = new BufferedOutputStream ( getOut ( right ) ) ; byte [ ] buf = new byte [ 8192 ] ; int next ; try { while ( ( next = in . read ( buf ) ) != - 1 ) { out . write ( buf , 0 , next ) ; } } catch ( IOException e ) { throw new GroovyRuntimeException ( "exception while reading process stream" , e ) ; } finally { closeWithWarning ( out ) ; closeWithWarning ( in ) ; } } } ) . start ( ) ; return right ; }
Allows one Process to asynchronously pipe data to another Process .