Here you can find the source of exec(String command)
Parameter | Description |
---|---|
command | a parameter |
static void exec(String command)
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { /**/*from www . j av a2 s .c om*/ * Utility function for debugging. Executes a command and pipes the result to * System.err * * @param command */ static void exec(String command) { try { Process p = Runtime.getRuntime().exec(command); BufferedReader stdInput = new BufferedReader( new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader( new InputStreamReader(p.getErrorStream())); // read the output from the command while ((command = stdInput.readLine()) != null) { System.err.println(command); } // read any errors from the attempted command while ((command = stdError.readLine()) != null) { System.err.println(command); } } catch (IOException e) { System.err.println("exception happened - here's what I know: "); e.printStackTrace(); } } }