Here you can find the source of execShell(String shell)
public static String execShell(String shell) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStreamReader; import java.io.LineNumberReader; public class Main { public static String execShell(String shell) throws IOException { Runtime rt = Runtime.getRuntime(); Process process = rt.exec(shell); return getOutputMsg(process); }//from w ww. j a v a 2s .com public static String getOutputMsg(Process process) throws IOException { StringBuilder sb = new StringBuilder(); LineNumberReader input = null; InputStreamReader ir = null; try { ir = new InputStreamReader(process.getInputStream()); input = new LineNumberReader(ir); String line; while ((line = input.readLine()) != null) { sb.append(line); System.out.println(line); } } finally { if (input != null) input.close(); if (ir != null) ir.close(); } return sb.toString(); } }