Here you can find the source of executeCommand(String cmd)
public static String executeCommand(String cmd)
//package com.java2s; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static String executeCommand(String cmd) { Process p;//from w ww .j av a2 s . c om try { p = Runtime.getRuntime().exec(cmd); InputStream stdoutStream = new BufferedInputStream(p.getInputStream()); StringBuffer buffer = new StringBuffer(); for (;;) { int c = stdoutStream.read(); if (c == -1) { break; } buffer.append((char) c); } String outputText = buffer.toString(); stdoutStream.close(); return outputText; } catch (IOException e) { e.printStackTrace(); return ""; } } }