Package org.jenkinsci.utils.process
Class ProcessInputStream
java.lang.Object
java.io.InputStream
org.jenkinsci.utils.process.ProcessInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
Represents a reader end of the pipe to a running process.
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasText()Reads the whole thing as a string.intvoidclose()Gives underlyingProcessintread()intread(byte[] b) intread(byte[] b, int off, int len) longskip(long n) verifyOrDieWith(String errorMessage) Waits for the process to complete.intwaitFor()Waits for the process to exit and returns its status code.Decorates the input stream by forcing an read error in case the process exits with non-zero exit code.Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
-
Constructor Details
-
ProcessInputStream
-
-
Method Details
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
getInputStream
-
getProcess
Gives underlyingProcess -
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
waitFor
Waits for the process to exit and returns its status code.- Throws:
InterruptedException
-
asText
Reads the whole thing as a string.- Throws:
IOExceptionInterruptedException
-
verifyOrDieWith
Waits for the process to complete. If the process returns a non-zero exit code, throwIOExceptionwith all the output from the process for diagnosis.- Throws:
IOExceptionInterruptedException
-
withErrorCheck
Decorates the input stream by forcing an read error in case the process exits with non-zero exit code.
-