Class ProcessReader
- java.lang.Object
-
- org.owasp.dependencycheck.utils.processing.ProcessReader
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class ProcessReader extends java.lang.Object implements java.lang.AutoCloseable
Utility to read the output from a `Process` and places the output into provide storage containers.- Author:
- Jeremy Long
-
-
Constructor Summary
Constructors Constructor Description ProcessReader(java.lang.Process process)
Creates a new reader for the given process.ProcessReader(java.lang.Process process, Processor<java.io.InputStream> processor)
Creates a new reader for the given process.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Waits for the process and related threads to complete.java.lang.String
getError()
Returns the error stream output from the process.java.lang.String
getOutput()
Returns the output from standard out from the process.void
readAll()
Reads the standard output and standard error from the process and waits for the process to complete.
-
-
-
Constructor Detail
-
ProcessReader
public ProcessReader(java.lang.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(java.lang.Process process, Processor<java.io.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 fromprocessor
- used to process the input stream from the process
-
-
Method Detail
-
getError
public java.lang.String getError()
Returns the error stream output from the process.- Returns:
- the error stream output
-
getOutput
public java.lang.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 java.lang.InterruptedException, java.io.IOException
Reads the standard output and standard error from the process and waits for the process to complete.- Throws:
java.lang.InterruptedException
- thrown if the processing threads are interruptedjava.io.IOException
- thrown if there is an error reading from the process
-
close
public void close() throws java.lang.InterruptedException, java.io.IOException
Waits for the process and related threads to complete.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.lang.InterruptedException
- thrown if the processing threads are interruptedjava.io.IOException
- thrown if there was an error reading from the process
-
-