Java tutorial
//package com.java2s; import java.io.DataOutputStream; public class Main { public static void execCommand(String paramString) { try { String[] arrayOfString = new String[1]; arrayOfString[0] = paramString; DataOutputStream localDataOutputStream = new DataOutputStream( Runtime.getRuntime().exec("su").getOutputStream()); for (int i = 0;; i++) { if (i >= 1) { localDataOutputStream.writeBytes("exit\n"); localDataOutputStream.flush(); localDataOutputStream.wait(); return; } localDataOutputStream.writeBytes(arrayOfString[i] + "\n"); localDataOutputStream.flush(); } } catch (Exception localException) { } } }