Java examples for Native OS:Linux
exec su Root Shell Command Silent
//package com.java2s; import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; public class Main { protected static int execRootCmdSilent(String paramString) throws IOException, InterruptedException { Process localProcess = Runtime.getRuntime().exec("su"); DataOutputStream localDataOutputStream = new DataOutputStream( (OutputStream) localProcess.getOutputStream()); localDataOutputStream.writeBytes((String) (String .valueOf(paramString) + "\n")); localDataOutputStream.flush();//from www . j a va2 s . c om localDataOutputStream.writeBytes("exit\n"); localDataOutputStream.flush(); localProcess.waitFor(); return localProcess.exitValue(); } }