Here you can find the source of runShell(String cmd)
public static boolean runShell(String cmd)
//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 boolean runShell(String cmd) { String[] cmds = new String[3]; cmds[0] = "/bin/sh"; cmds[1] = "-c"; cmds[2] = cmd;//www.j ava2 s.c o m System.out.println("shell command: "); System.out.println(cmd); try { Process process = Runtime.getRuntime().exec(cmds); BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; while ((line = br.readLine()) != null) { System.out.println(line); } process.waitFor(); br.close(); Thread.sleep(1000); } catch (IOException e) { e.printStackTrace(); return false; } catch (InterruptedException e) { e.printStackTrace(); return false; } return true; } }