Here you can find the source of execCommand(String command)
private static String execCommand(String command)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { private static String execCommand(String command) { String result = null;//from w ww .ja v a 2s . c om String newLine = System.getProperty("line.separator"); try { Process p = Runtime.getRuntime().exec(command); p.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); StringBuilder response = new StringBuilder(); String line = reader.readLine(); while (line != null) { response.append(line + newLine); line = reader.readLine(); } result = response.toString(); } catch (Exception e) { result = null; } return result; } }