protected Pair < Integer , InputStream > executeCommand ( String command ) { int resultVal = 1 ; InputStream inputStream = null ; try { logger . debug ( "Executing command: {}" , command ) ; Process process = Runtime . getRuntime ( ) . exec ( command ) ; resultVal = process . waitFor ( ) ; inputStream = process . getInputStream ( ) ; } catch ( InterruptedException e ) { logger . info ( "Execution of {} failed: code - {} ; message - {}" , command , resultVal , e . getMessage ( ) ) ; Thread . currentThread ( ) . interrupt ( ) ; } catch ( IOException e ) { logger . info ( "Execution of {} failed: code - {} ; message - {}" , command , resultVal , e . getMessage ( ) ) ; } if ( inputStream == null ) { // Create an empty InputStream instead of returning a null inputStream = new InputStream ( ) { @ Override public int read ( ) throws IOException { return - 1 ; } } ; } return new Pair <> ( resultVal , inputStream ) ; }
from old command s stream and the new command s stream