protected static String runCommand ( String ... command ) { try { final Process p = Runtime . getRuntime ( ) . exec ( command ) ; if ( p == null ) { return null ; } final StringBuilder bStr = new StringBuilder ( ) ; try ( InputStream standardOutput = p . getInputStream ( ) ) { final byte [ ] buffer = new byte [ BUFFER_SIZE ] ; int len ; while ( ( len = standardOutput . read ( buffer ) ) > 0 ) { bStr . append ( new String ( buffer , 0 , len ) ) ; } p . waitFor ( ) ; return bStr . toString ( ) ; } } catch ( Exception e ) { return null ; } }
Run a shell command .