src/main/java/Main.java
/**
     * Execute the inputted command.
     * @param cmd command string.
     * @return command result string.
     */
Execute the inputted command.
@param cmd command string.
@return command result string.
Execute the inputted command . @param cmd command string . @return command result string .
public static String exec(String cmd) {
        try {
            StringBuilder sb = new StringBuilder();
            Process process = Runtime.getRuntime().exec(cmd);
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                sb.append(line).append("\n");
            }
            bufferedReader.close();
            process.destroy();
            return sb.toString();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
public static String exec ( String cmd ) { try { StringBuilder sb = new StringBuilder ( ) ; Process process = Runtime . getRuntime ( ) . exec ( cmd ) ; BufferedReader bufferedReader = new BufferedReader ( new InputStreamReader ( process . getInputStream ( ) ) ) ; String line ; while ( ( line = bufferedReader . readLine ( ) ) != null ) { sb . append ( line ) . append ( "\n" ) ; } bufferedReader . close ( ) ; process . destroy ( ) ; return sb . toString ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return null ; }
Execute the inputted command.
Execute the inputted command .