Here you can find the source of executeCommand(String comand)
public static void executeCommand(String comand) throws IOException, InterruptedException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void executeCommand(String comand) throws IOException, InterruptedException { Process p;// w ww .ja v a2 s . c o m try { p = Runtime.getRuntime().exec(comand); p.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); StringBuffer sb = new StringBuffer(); String line = reader.readLine(); sb.append(line); while (line != null) { line = reader.readLine(); sb.append(line); System.out.println(line); } } catch (Exception e) { e.printStackTrace(); } } }