Here you can find the source of runCommand(String cmd)
protected static String runCommand(String cmd)
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { /**/*from w w w . j av a 2 s .co m*/ * Run the specified command and return the output as a string. */ protected static String runCommand(String cmd) { try { Process p = Runtime.getRuntime().exec(cmd); BufferedReader cin = new BufferedReader(new InputStreamReader(p.getInputStream())); StringBuilder buffer = new StringBuilder(); String line = ""; while (line != null) { buffer.append(line); line = cin.readLine(); } cin.close(); return buffer.toString(); } catch (IOException e) { // don't want to log anything for the client to know what we are doing. // This will almost always be thrown/caught when the cmd isn't there. return null; } } }