Here you can find the source of executeCommand(String command)
public static String executeCommand(String command) throws IOException
//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 executeCommand(String command) throws IOException { Process process = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", command }); BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); StringBuilder output = new StringBuilder(); String line;// w w w . j a v a 2 s . c o m while ((line = input.readLine()) != null) { output.append(line); output.append("\n"); } input.close(); return output.toString(); } }