Here are some hints how to find the answer.
The Java part
Google for
javadoc RunTime
. It's usually the fastest way of getting the proper Oracle documentation.The first link is http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html, follow it.
On the javadoc page, search for
exec(String[] cmdarray)
. Follow the link (click on theexec
name of the method).Read the javadoc:
- Executes the specified command and arguments in a separate process.
- Behaves in exactly the same way as the invocation
exec(cmdarray, null, null)
- Find the section describing the same method with three params (click on the
exec
name).
Read the javadoc for the
exec(String[], String[], File)
method. While reading it, take into account that the last two parameters arenull
. You find that
Executes the specified command and arguments in a separate process... Given an array of strings cmdarray, representing the tokens of a command line... mdarray - array containing the command to call and its arguments
It means that your code
Runtime.getRuntime().exec(new String[]{"su","-c","reboot bootloader"});
does the same as if you run from your command line the command su
giving it some arguments:
su -c 'reboot bootloader'
The Linux part
Use google and search for su command line arguments. Here you find that
su is usually the simplest and most convenient way to change the ownership of a login session to root or to any other user... Among the most commonly used of su's few options is -c, which tells su to execute the command that directly follows it on the same line.
So as you can see, your code calls the command reboot bootloader
as a root.
Your own part
Next time, follow the above described procedure on your own :) I now invested a lot of time into you, do not waste it please :)
If you felt a slight sarcastic undertone in my answer, you are probably not far from the truth :) However please notice that it is not a pure RFTM answer, it really does answer your question and furthermore it teaches you how to find the answer on your own.