List of utility methods to do exec
void | exec(ArrayList exec ProcessBuilder ps = new ProcessBuilder(args); ps.redirectErrorStream(true); if (path != null) { ps.directory(path); Process pr = ps.start(); BufferedReader ins = new BufferedReader(new InputStreamReader(pr.getInputStream())); String line; ... |
Process | exec(File dir, String cmd) exec String fullCmd = dir.getPath() + "/" + cmd; Runtime runtime = Runtime.getRuntime(); return runtime.exec(fullCmd); |
byte[] | exec(final String cmd, final String[] args, final byte[] in, final File dir) Creates and runs a new Process with the given arguments, taking cmd as a pattern for String#format(String,Object) with arguments args . final StringBuilder sb = new StringBuilder(); if (cmd.contains(" ")) { sb.append('"' + cmd + '"'); } else { sb.append(cmd); for (final String arg : args) { sb.append(' ' + arg); ... |
String | exec(List exec String[] cmdp = cmd.toArray(new String[cmd.size()]); String[] envp = { "PATH=" + binDir.getAbsolutePath() }; Process proc = Runtime.getRuntime().exec(cmdp, envp, workDir); if (tossErrorOutput) { pullStream(proc.getErrorStream()); try { int err = proc.waitFor(); ... |
BufferedReader | exec(String args) exec String[] splitArgs = args.split(" "); ProcessBuilder builder = new ProcessBuilder(splitArgs); Process p = builder.start(); p.getOutputStream().flush(); p.getOutputStream().close(); return new BufferedReader(new InputStreamReader(p.getInputStream())); |
Process | exec(String cmd) Execute a system command and return the attached process. return exec(cmd, "."); |
String[] | exec(String cmd) exec Process p = Runtime.getRuntime().exec(cmd); p.waitFor(); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); String s = null; StringBuilder sbout = new StringBuilder(); while ((s = stdInput.readLine()) != null) { sbout.append(s); StringBuilder sberr = new StringBuilder(); BufferedReader stdErrIn = new BufferedReader(new InputStreamReader(p.getErrorStream())); while ((s = stdErrIn.readLine()) != null) { sberr.append(s); String[] ret = new String[2]; ret[0] = sbout.toString(); ret[1] = sberr.toString(); return ret; |
void | exec(String cmd) exec try { Process child = Runtime.getRuntime().exec(cmd); child.waitFor(); InputStream in = child.getInputStream(); int c; while ((c = in.read()) != -1) { System.out.print(c); in.close(); } catch (IOException e) { System.err.println("Error: could execute command: " + cmd); e.printStackTrace(); } catch (InterruptedException e) { System.err.println("Error: command interrupted: " + cmd); e.printStackTrace(); |
String | exec(String cmd) exec Process process = null; List<String> processList = new ArrayList<String>(); try { process = Runtime.getRuntime().exec(cmd); BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); String line = ""; while ((line = input.readLine()) != null) { processList.add(line); ... |
String | exec(String cmd) exec try { String[] cmdA = { "/bin/sh", "-c", cmd }; Process process = Runtime.getRuntime().exec(cmdA); LineNumberReader br = new LineNumberReader(new InputStreamReader(process.getInputStream())); StringBuffer sb = new StringBuffer(); String line; while ((line = br.readLine()) != null) { System.out.println(line); ... |