jodd-core/src/main/java/jodd/util/CommandLine.java
public ProcessRunner.ProcessResult run() {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();

		out = err = baos;

		try {
			baos.write(StringUtil.join(cmdLine, ' ').getBytes());
			baos.write(StringPool.BYTES_NEW_LINE);
		}
		catch (IOException ignore) {
		}

		ProcessBuilder processBuilder = new ProcessBuilder();

		processBuilder.command(cmdLine);

		if (cleanEnvironment) {
			processBuilder.environment().clear();
		}
		if (env != null) {
			processBuilder.environment().putAll(env);
		}

		processBuilder.directory(workingDirectory);

		Process process = null;
		try {
			process = processBuilder.start();
		}
		catch (IOException ioex) {
			return writeException(baos, ioex);
		}

		StreamGobbler outputGobbler = new StreamGobbler(process.getInputStream(), out, outPrefix);
		StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), err, errPrefix);

		outputGobbler.start();
		errorGobbler.start();

		int result;

		try {
			result = process.waitFor();
		}
		catch (InterruptedException iex) {
			return writeException(baos, iex);
		}

		outputGobbler.waitFor();
		errorGobbler.waitFor();

		return new ProcessRunner.ProcessResult(result, baos.toString());
	}
public ProcessRunner.ProcessResult run() {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();

		out = err = baos;

		try {
			baos.write(StringUtil.join(cmdLine, ' ').getBytes());
			baos.write(StringPool.BYTES_NEW_LINE);
		}
		catch (IOException ignore) {
		}

		ProcessBuilder processBuilder = new ProcessBuilder();

		processBuilder.command(cmdLine);

		if (cleanEnvironment) {
			processBuilder.environment().clear();
		}
		if (env != null) {
			processBuilder.environment().putAll(env);
		}

		processBuilder.directory(workingDirectory);

		Process process = null;
		try {
			process = processBuilder.start();
		}
		catch (IOException ioex) {
			return writeException(baos, ioex);
		}

		StreamGobbler outputGobbler = new StreamGobbler(process.getInputStream(), out, outPrefix);
		StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), err, errPrefix);

		outputGobbler.start();
		errorGobbler.start();

		int result;

		try {
			result = process.waitFor();
		}
		catch (InterruptedException iex) {
			return writeException(baos, iex);
		}

		outputGobbler.waitFor();
		errorGobbler.waitFor();

		return new ProcessRunner.ProcessResult(result, baos.toString());
	}
public ProcessRunner . ProcessResult run ( ) { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; out = err = baos ; try { baos . write ( StringUtil . join ( cmdLine , ' ' ) . getBytes ( ) ) ; baos . write ( StringPool . BYTES_NEW_LINE ) ; } catch ( IOException ignore ) { } ProcessBuilder processBuilder = new ProcessBuilder ( ) ; processBuilder . command ( cmdLine ) ; if ( cleanEnvironment ) { processBuilder . environment ( ) . clear ( ) ; } if ( env != null ) { processBuilder . environment ( ) . putAll ( env ) ; } processBuilder . directory ( workingDirectory ) ; Process process = null ; try { process = processBuilder . start ( ) ; } catch ( IOException ioex ) { return writeException ( baos , ioex ) ; } StreamGobbler outputGobbler = new StreamGobbler ( process . getInputStream ( ) , out , outPrefix ) ; StreamGobbler errorGobbler = new StreamGobbler ( process . getErrorStream ( ) , err , errPrefix ) ; outputGobbler . start ( ) ; errorGobbler . start ( ) ; int result ; try { result = process . waitFor ( ) ; } catch ( InterruptedException iex ) { return writeException ( baos , iex ) ; } outputGobbler . waitFor ( ) ; errorGobbler . waitFor ( ) ; return new ProcessRunner . ProcessResult ( result , baos . toString ( ) ) ; }
Runs command and returns process result.
Runs command and returns process result .