Class ProcessResult

java.lang.Object
org.codehaus.groovy.runtime.ProcessResult

public class ProcessResult extends Object
Captures the result of executing an external process, including the standard output, standard error, and exit code.
 def result = "ls -la".execute().waitForResult()
 assert result.ok
 println result.out
 
Since:
6.0.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    ProcessResult(String out, String err, int exitCode)
    Constructs a ProcessResult with the specified output, error, and exit code.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the standard error of the process as a String.
    int
    Returns the exit code of the process.
    Returns the standard output of the process as a String.
    boolean
    Returns true if the process exited with code 0.
    Returns a string representation of this process result, including the exit code and abbreviated output/error.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ProcessResult

      public ProcessResult(String out, String err, int exitCode)
      Constructs a ProcessResult with the specified output, error, and exit code.
      Parameters:
      out - the standard output of the process
      err - the standard error of the process
      exitCode - the process exit code
  • Method Details

    • getOut

      public String getOut()
      Returns the standard output of the process as a String.
    • getErr

      public String getErr()
      Returns the standard error of the process as a String.
    • getExitCode

      public int getExitCode()
      Returns the exit code of the process.
    • isOk

      public boolean isOk()
      Returns true if the process exited with code 0.
    • toString

      public String toString()
      Returns a string representation of this process result, including the exit code and abbreviated output/error.
      Overrides:
      toString in class Object