Java Utililty Methods exec

List of utility methods to do exec

Description

The list of methods to do exec are organized into topic(s).

Method

Processexec(String[] args)
exec
ProcessBuilder processBuilder = new ProcessBuilder(args);
return processBuilder.start();
StringexecAdbCmd(String cmd)
exec Adb Cmd
String result = "";
Runtime runtime = Runtime.getRuntime();
Process process = null;
BufferedReader bufferedReader = null;
try {
    process = runtime.exec(cmd);
    bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream(), "utf-8"));
    String buffer;
...
StringexecAndGetOutput(ProcessBuilder builder)
exec And Get Output
Process process = builder.redirectErrorStream(true).start();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
try {
    return reader.readLine();
} finally {
    reader.close();
intexecCmd(String cmd)
exec Cmd
Process p = Runtime.getRuntime().exec(cmd);
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
    System.out.println(line);
return 0;
StringexecCmd(String cmd)
execute a command in the shell of the OS
Process p = Runtime.getRuntime().exec(cmd);
InputStream is = p.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
String line = " a";
while ((line = br.readLine()) != null) {
    pw.println(line);
...
StringexecCmd(String cmd, File where)
exec Cmd
Process p = Runtime.getRuntime().exec(cmd, null, where);
Scanner s = new Scanner(p.getInputStream());
String ret = "";
s.useDelimiter("\\A");
if (s.hasNext())
    ret = s.next();
s.close();
return ret;
...
StringexecCmd(String command)
exec Cmd
BufferedReader br = null;
StringBuffer stringBuffer = new StringBuffer();
try {
    Process p = Runtime.getRuntime().exec(command);
    br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line = null;
    while ((line = br.readLine()) != null) {
        if ("".equals(line.trim()))
...
StringexecCmdWindows(String cmd)
exec Cmd Windows
java.util.Scanner s = new java.util.Scanner(
        Runtime.getRuntime().exec(String.format("cmd /c %s", cmd)).getInputStream()).useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
intexecCommand(String cmd)
exec Command
return execCommand(cmd, null, true, true);
StringexecCommand(String command)
exec Command
String result = null;
String newLine = System.getProperty("line.separator");
try {
    Process p = Runtime.getRuntime().exec(command);
    p.waitFor();
    BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
    StringBuilder response = new StringBuilder();
    String line = reader.readLine();
...