public static String qx ( String ... cmd ) { StringBuilder sb = new StringBuilder ( ) ; try { Process proc = Runtime . getRuntime ( ) . exec ( cmd ) ; BufferedReader stdInput = new BufferedReader ( new InputStreamReader ( proc . getInputStream ( ) ) ) ; BufferedReader stdError = new BufferedReader ( new InputStreamReader ( proc . getErrorStream ( ) ) ) ; String s ; while ( ( s = stdInput . readLine ( ) ) != null ) { sb . append ( s ) . append ( System . getProperty ( "line.separator" ) ) ; } while ( ( s = stdError . readLine ( ) ) != null ) { sb . append ( s ) . append ( System . getProperty ( "line.separator" ) ) ; } } catch ( IOException e ) { logger . log ( Level . SEVERE , null , e ) ; throw new RuntimeException ( e ) ; } return sb . toString ( ) ; }
Executes a system command and returns its result .