List of utility methods to do exec
boolean | exec(String cmd) exec try { String cmds[] = null; if (isNT()) { cmds = new String[3]; cmds[0] = "cmd"; cmds[1] = "/c"; cmds[2] = cmd; } else { ... |
Process | exec(String cmd, File dir) exec return exec(cmd, dir, System.out, null);
|
String | exec(String command) exec String ls = System.getProperty("line.separator"); StringBuffer result = new StringBuffer(); ArrayList<String> argsArray = new ArrayList<String>(); StreamTokenizer st = new StreamTokenizer(new StringReader(command)); st.resetSyntax(); st.wordChars('a', 'z'); st.wordChars('A', 'Z'); st.wordChars('0', '9'); ... |
Process | exec(String command) exec return exec(command, null);
|
String | exec(String command) exec try { Process process = Runtime.getRuntime().exec(command); InputStream errorStream = process.getErrorStream(); byte[] buffer = new byte[1024]; int readBytes; StringBuilder stringBuilder = new StringBuilder(); while ((readBytes = errorStream.read(buffer)) > 0) { stringBuilder.append(new String(buffer, 0, readBytes)); ... |
void | exec(String command) Utility function for debugging. try { Process p = Runtime.getRuntime().exec(command); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); while ((command = stdInput.readLine()) != null) { System.err.println(command); while ((command = stdError.readLine()) != null) { ... |
List | exec(String command) exec try { List<String> retList = new ArrayList<String>(); String line; Process p = Runtime.getRuntime().exec(command); BufferedReader bri = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader bre = new BufferedReader(new InputStreamReader(p.getErrorStream())); while ((line = bri.readLine()) != null) { retList.add(line); ... |
Process | exec(String command) exec return Runtime.getRuntime().exec(command);
|
int | exec(String command, String workingDir) exec try { Process process = Runtime.getRuntime().exec(command, null, workingDir != null ? new File(workingDir) : null); BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); String brline; while ((brline = br.readLine()) != null) { System.out.println(brline); br = new BufferedReader(new InputStreamReader(process.getErrorStream())); while ((brline = br.readLine()) != null) { System.out.println(brline); process.waitFor(); return process.exitValue(); } catch (IOException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); |
Process | exec(String command, String[] args_, String[] environment) Executes the commands with args and environemnt in a separate process. String[] args = new String[1]; if (args_ != null) { args = new String[args_.length + 1]; for (int i = 0; i < args_.length; i++) args[i + 1] = args_[i]; args[0] = command; return Runtime.getRuntime().exec(args, environment); ... |