Here you can find the source of runCommandWithOutput(String cmd)
public static void runCommandWithOutput(String cmd) 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 void runCommandWithOutput(String cmd) throws IOException { Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(cmd); BufferedReader br = new BufferedReader(new InputStreamReader(pr.getInputStream())); String line = ""; while ((br.readLine()) != null) { System.out.println(line); }/*from w w w.java 2 s . c om*/ } }