Java tutorial
//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 String do_exec(String cmd) { String s = "/n"; try { Process p = Runtime.getRuntime().exec(cmd); BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = null; while ((line = in.readLine()) != null) { s += line + "/n"; } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return s; } }