Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import android.util.Log; public class Main { public static void execCmd(String szCmd, boolean bCatchLog) { try { Log.d("PvTorrent_proc", "execCmd=" + szCmd); Runtime runtime = Runtime.getRuntime(); Process process = runtime.exec(szCmd); if (bCatchLog) { InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line = null; while (null != (line = br.readLine())) { Log.e("PvTorrent_proc", line); } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block Log.d("PvTorrent_proc", e.toString()); } } }