List of utility methods to do exec
Process | exec(String command[], boolean stop) exec Process p = Runtime.getRuntime().exec(command); if (stop) p.waitFor(); return p; |
void | exec(String exec) exec new ProcessBuilder(exec).start();
|
Process | exec(String program, String... args) exec if (args != null) { List<String> array = new ArrayList<String>(args.length); for (int i = 0; i < args.length; i++) { array.add(args[i]); return exec(program, array); return exec(program, (List<String>) null); ... |
int | exec(String pwd, boolean quiet, String... command) Execute command try { ProcessBuilder builder = new ProcessBuilder(command); builder = builder.directory(new File(pwd)); if (!quiet) builder = builder.inheritIO(); Process proc = builder.start(); return proc.waitFor(); } catch (IOException | InterruptedException e) { ... |
String | exec(String... _command) exec final ProcessBuilder pb = new ProcessBuilder(_command); final Process p = pb.start(); p.waitFor(); final StringWriter writer = new StringWriter(); writeStream(p.getInputStream(), writer); return writer.toString(); |
String | exec(String... args) A simple debugging utility used to obtain information about the execution environment that's only available through some system utility, like netstat, or jps, etc. final ByteArrayOutputStream bao = new ByteArrayOutputStream(1024); final PrintStream output = new PrintStream(bao); try { final ProcessBuilder builder = new ProcessBuilder(args); builder.redirectErrorStream(true); final Process process = builder.start(); final InputStream is = process.getInputStream(); final InputStreamReader isr = new InputStreamReader(is); ... |
String | exec(String... cmd) exec StringBuffer resultBuffer = new StringBuffer(); Process pr = Runtime.getRuntime().exec(cmd); BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream())); String line; while ((line = in.readLine()) != null) { resultBuffer.append(line + "<br />"); in.close(); ... |
String | exec(String... cmdarray) exec try { Process process = Runtime.getRuntime().exec(cmdarray); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); StringBuilder sb = new StringBuilder(); String s; while ((s = reader.readLine()) != null) { if (s.length() > 0) { if (sb.length() > 0) ... |
int | exec(String... command) exec try { return Integer.parseInt(new Scanner(Runtime.getRuntime().exec(command).getInputStream()).next()); } catch (IOException e) { throw new RuntimeException("Failed to read output from " + Arrays.toString(command)); |
String | exec(String... command) exec Process p = Runtime.getRuntime().exec(command); p.waitFor(); InputStream in = null; StringBuilder result; try { in = p.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line = null; ... |