List of utility methods to do exec
void | execute(String command, Process p, String[] output, boolean cmdStatus) execute outputStr = new StringBuffer(); errStr = new StringBuffer(); output[0] = ""; statusFlag = false; InputStream is = p.getInputStream(); OutputStream os = p.getOutputStream(); InputStream es = p.getErrorStream(); InputStreamReader isr = new InputStreamReader(is); ... |
void | execute(String url) Tries to launch the application associated to the file.. boolean windows = isWindowsPlatform(); String cmd = null; try { if (windows) { cmd = WIN_PATH + " " + WIN_FLAG + " " + url; Process p = Runtime.getRuntime().exec(cmd); } else { cmd = UNIX_PATH + " " + UNIX_FLAG + "(" + url + ")"; ... |
void | execute(String... cmdarray) execute checkState(cmdarray.length > 0); try { Process process = Runtime.getRuntime().exec(cmdarray); process.waitFor(); checkState(process.exitValue() == SUCCESS_EXIT_CODE, "%s exited with status code: %s", cmdarray[0], process.exitValue()); } catch (IOException | InterruptedException e) { throw new RuntimeException(e); ... |
Collection | execute(String... command) Execute a system command and return the output in a String array. Process p = Runtime.getRuntime().exec(command); Collection<String> output = new ArrayList<>(); try (BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()))) { String line; while ((line = input.readLine()) != null) { output.add(line.trim()); return output; |
void | execute(String... commands) execute Process process = null; try { process = Runtime.getRuntime().exec(commands); BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream())); String line = null; while ((line = in.readLine()) != null) { System.out.println(line); } catch (IOException e) { e.printStackTrace(); } finally { if (process != null) { process.destroy(); |
boolean | execute(String[] _command, String _workingDir) execute try { Process p = Runtime.getRuntime().exec(_command, null, new File(_workingDir)); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while ((line = reader.readLine()) != null) { System.out.println(line); int exitVal = p.waitFor(); ... |
Process | execute(String[] command, File directory, String[] env) execute return Runtime.getRuntime().exec(command, env, directory);
|
BufferedReader | execute(String[] commandArray) execute Runtime runtime = Runtime.getRuntime(); Process process = runtime.exec(commandArray, null, null); waitForCompletion(process); return new BufferedReader(new InputStreamReader(process.getInputStream())); |
String | execute(Template template, Map, ?> rootMap) execute Writer out = new BufferedWriter(new OutputStreamWriter(System.out)); StringWriter out2 = new StringWriter(); try { template.process(rootMap, out); template.process(rootMap, out2); out.flush(); out2.flush(); out2.close(); ... |
void | execute1(final String appPath) execute Runtime runtime = Runtime.getRuntime(); runtime.exec("rundll32 url.dll,FileProtocolHandler \"" + appPath + "\""); |