Here you can find the source of executeCommand(String command)
public static String executeCommand(String command)
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static String executeCommand(String command) { StringBuffer output = new StringBuffer(); Process p;//w ww .java2 s .co m try { p = Runtime.getRuntime().exec(command); p.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while ((line = reader.readLine()) != null) { output.append(line + "\n"); } } catch (Exception e) { e.printStackTrace(); } return output.toString(); } }