Package org.forgerock.http.io
Class FailableInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.forgerock.http.io.FailableInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class FailableInputStream extends FilterInputStream
Wraps an existingInputStream, supporting a failed state that is checked before and after each operation.
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description FailableInputStream(InputStream in)Constructs a newFailableInputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()intread()intread(byte[] b)intread(byte[] b, int off, int len)voidreset()voidsetFailed(Throwable cause)Sets this stream into a failed state.longskip(long n)-
Methods inherited from class java.io.FilterInputStream
close, mark, markSupported
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
FailableInputStream
public FailableInputStream(InputStream in)
Constructs a newFailableInputStream.- Parameters:
in- the underlying input stream
-
-
Method Detail
-
read
public int read() throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
public int read(byte[] b) throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
public long skip(long n) throws IOException- Overrides:
skipin classFilterInputStream- Throws:
IOException
-
available
public int available() throws IOException- Overrides:
availablein classFilterInputStream- Throws:
IOException
-
reset
public void reset() throws IOException- Overrides:
resetin classFilterInputStream- Throws:
IOException
-
setFailed
public void setFailed(Throwable cause)
Sets this stream into a failed state.- Parameters:
cause- The cause of the failure.
-
-