Here you can find the source of runShellCommand(String[] cmd, StringBuilder outputLines, StringBuilder errorLines)
String
array.
public static void runShellCommand(String[] cmd, StringBuilder outputLines, StringBuilder errorLines) throws IOException
//package com.java2s; import java.io.*; public class Main { /**/* w w w . j a v a 2 s. co m*/ * Runs the shell command which is specified, along with its arguments, in the * given <code>String</code> array. If there is any regular output or error * output, it is appended to the given <code>StringBuilder</code>s. */ public static void runShellCommand(String[] cmd, StringBuilder outputLines, StringBuilder errorLines) throws IOException { Process p = Runtime.getRuntime().exec(cmd); if (outputLines != null) { BufferedReader in = new BufferedReader(new InputStreamReader( p.getInputStream())); String line; while ((line = in.readLine()) != null) { outputLines.append(line); } } if (errorLines != null) { BufferedReader err = new BufferedReader(new InputStreamReader( p.getErrorStream())); String line; while ((line = err.readLine()) != null) { errorLines.append(line); } } } /** * Runs the shell command which is specified, along with its arguments, in the * given <code>String</code>. If there is any regular output or error output, * it is appended to the given <code>StringBuilder</code>s. */ public static void runShellCommand(String cmd, StringBuilder outputLines, StringBuilder errorLines) throws IOException { runShellCommand(new String[] { cmd }, outputLines, errorLines); } /** * Runs the shell command which is specified, along with its arguments, in the * given <code>String</code> array. If there is any regular output, it is * appended to the given <code>StringBuilder</code>. If there is any error * output, it is swallowed (!). */ public static void runShellCommand(String[] cmd, StringBuilder outputLines) throws IOException { runShellCommand(cmd, outputLines, null); } /** * Runs the shell command which is specified, along with its arguments, in the * given <code>String</code>. If there is any regular output, it is appended * to the given <code>StringBuilder</code>. If there is any error output, it * is swallowed (!). */ public static void runShellCommand(String cmd, StringBuilder outputLines) throws IOException { runShellCommand(new String[] { cmd }, outputLines, null); } /** * Runs the shell command which is specified, along with its arguments, in the * given <code>String</code> array. If there is any output, it is swallowed * (!). */ public static void runShellCommand(String[] cmd) throws IOException { runShellCommand(cmd, null, null); } /** * Runs the shell command which is specified, along with its arguments, in the * given <code>String</code>. If there is any output, it is swallowed (!). */ public static void runShellCommand(String cmd) throws IOException { runShellCommand(new String[] { cmd }, null, null); } }