Here you can find the source of runShell(String shStr)
public static List runShell(String shStr) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.InputStreamReader; import java.io.LineNumberReader; import java.util.ArrayList; import java.util.List; public class Main { public static List runShell(String shStr) throws Exception { List<String> strList = new ArrayList(); Process process;//from w w w.j a v a2s.c o m process = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", shStr }, null, null); InputStreamReader ir = new InputStreamReader(process.getInputStream()); LineNumberReader input = new LineNumberReader(ir); String line; process.waitFor(); while ((line = input.readLine()) != null) { strList.add(line); } return strList; } }