public void gatherOutput ( ) { try { final Copier errorCopier = new Copier ( this . processErrorStream ) ; final Copier outputCopier = new Copier ( this . processOutputStream ) ; errorCopier . start ( ) ; outputCopier . start ( ) ; errorCopier . join ( ) ; outputCopier . join ( ) ; this . stderr = new String [ errorCopier . getLines ( ) . size ( ) ] ; errorCopier . getLines ( ) . copyInto ( this . stderr ) ; this . stdout = new String [ outputCopier . getLines ( ) . size ( ) ] ; outputCopier . getLines ( ) . copyInto ( this . stdout ) ; } catch ( final Exception e ) { this . stderr = this . stdout = new String [ 0 ] ; } }
Reads concurrently both the process standard output and standard error . The standard error is copied to the stderr string array field . The standard output is copied to the stdout string array field . Both fields are set to an empty array in case of any error .