Here you can find the source of runCommand(String command)
public static String runCommand(String command) throws IOException, InterruptedException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String runCommand(String command) throws IOException, InterruptedException { Process p = Runtime.getRuntime().exec(command); p.waitFor();/*from w w w . j a v a 2 s . c om*/ BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; StringBuilder sb = new StringBuilder(); while ((line = reader.readLine()) != null) sb.append(line + "\n"); return sb.toString(); } }