X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fio%2FSimpleProcess.java;h=744386445d15c1e7d6fa1ce63876e712c55f5100;hb=0d8d8f24656e585ee75558cfd6a4c661f8f14985;hp=d4f7b16b9def2a825d15ed2fb6924e692f54afb3;hpb=da48a523c81e59fe0eac34e43d12937396161f25;p=utils diff --git a/support/general/src/main/java/org/wamblee/io/SimpleProcess.java b/support/general/src/main/java/org/wamblee/io/SimpleProcess.java index d4f7b16b..74438644 100644 --- a/support/general/src/main/java/org/wamblee/io/SimpleProcess.java +++ b/support/general/src/main/java/org/wamblee/io/SimpleProcess.java @@ -32,30 +32,30 @@ public class SimpleProcess { private static final Log LOG = LogFactory.getLog(SimpleProcess.class); - private File _directory; + private File directory; - private String[] _cmd; + private String[] cmd; - private String _stdout; - private String _stderr; + private String stdout; + private String stderr; public SimpleProcess(File aDirectory, String[] aCmd) { - _directory = aDirectory; - _cmd = aCmd; + directory = aDirectory; + cmd = aCmd; } /** * @return the stdout */ public String getStdout() { - return _stdout; + return stdout; } /** * @return the stderr */ public String getStderr() { - return _stderr; + return stderr; } /** @@ -72,22 +72,22 @@ public class SimpleProcess { private int runImpl() throws IOException { try { String fullcmd = ""; - for (String part: _cmd) { + for (String part: cmd) { fullcmd += " " + part; } - LOG.debug("Executing '" + fullcmd + "' in directory '" + _directory + LOG.debug("Executing '" + fullcmd + "' in directory '" + directory + "'"); - java.lang.Process proc = Runtime.getRuntime().exec(_cmd, null, _directory); + java.lang.Process proc = Runtime.getRuntime().exec(cmd, null, directory); // Read standard output and error in separate threads to avoid // deadlock. - StringWriter stdout = new StringWriter(); - StringWriter stderr = new StringWriter(); + StringWriter myStdout = new StringWriter(); + StringWriter myStderr = new StringWriter(); Thread stdoutReader = readAndLogStream("STDOUT> ", proc - .getInputStream(), stdout); + .getInputStream(), myStdout); Thread stderrReader = readAndLogStream("STDERR> ", proc - .getErrorStream(), stderr); + .getErrorStream(), myStderr); try { proc.waitFor(); @@ -100,8 +100,8 @@ public class SimpleProcess { waitForReader(stdoutReader); waitForReader(stderrReader); - _stdout = stdout.toString(); - _stderr = stderr.toString(); + stdout = myStdout.toString(); + stderr = myStderr.toString(); if (proc.exitValue() != 0) { LOG.warn("Exit value was non-zero: " + this); @@ -160,9 +160,9 @@ public class SimpleProcess { @Override public String toString() { String fullcmd = ""; - for (String part: _cmd) { + for (String part: cmd) { fullcmd += part + " "; } - return "process(dir = '" + _directory + "', cmd = '" + fullcmd + "')"; + return "process(dir = '" + directory + "', cmd = '" + fullcmd + "')"; } }