Here you can find the source of executeCommand(String command)
public static String executeCommand(String command) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.InputStream; import java.util.Scanner; public class Main { public static String executeCommand(String command) throws IOException { Process proc = Runtime.getRuntime().exec(command); try (InputStream stream = proc.getInputStream()) { try (Scanner s = new Scanner(stream).useDelimiter("\\A")) { return s.hasNext() ? s.next() : ""; }/*from www .j a v a 2s. c o m*/ } } }