Class ProcessReader

java.lang.Object
org.owasp.dependencycheck.utils.processing.ProcessReader
All Implemented Interfaces:
AutoCloseable

public class ProcessReader extends Object implements AutoCloseable
Utility to read the output from a `Process` and places the output into provide storage containers.
Author:
Jeremy Long
  • Constructor Details

    • ProcessReader

      public ProcessReader(Process process)
      Creates a new reader for the given process. The output from the process is written to the provided stores.
      Parameters:
      process - the process to read from
    • ProcessReader

      public ProcessReader(Process process, Processor<InputStream> processor)
      Creates a new reader for the given process. The output from the process is written to the provided stores.
      Parameters:
      process - the process to read from
      processor - used to process the input stream from the process
  • Method Details

    • getError

      public String getError()
      Returns the error stream output from the process.
      Returns:
      the error stream output
    • getOutput

      public String getOutput()
      Returns the output from standard out from the process.
      Returns:
      the output from standard out from the process
    • readAll

      public void readAll() throws InterruptedException, IOException
      Reads the standard output and standard error from the process and waits for the process to complete.
      Throws:
      InterruptedException - thrown if the processing threads are interrupted
      IOException - thrown if there is an error reading from the process
    • close

      public void close() throws InterruptedException, IOException
      Waits for the process and related threads to complete.
      Specified by:
      close in interface AutoCloseable
      Throws:
      InterruptedException - thrown if the processing threads are interrupted
      IOException - thrown if there was an error reading from the process