Java tutorial
//package com.java2s; //License from project: Apache License import java.io.DataOutputStream; public class Main { public static void RunAsRootNoOutput(String[] cmds) { try { Process p = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(p.getOutputStream()); for (String tmpCmd : cmds) { os.writeBytes(tmpCmd + "\n"); } os.writeBytes("exit\n"); os.flush(); } catch (Exception e) { e.printStackTrace(); } } }