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 int
available()
int
read()
int
read(byte[] b)
int
read(byte[] b, int off, int len)
void
reset()
void
setFailed(Throwable cause)
Sets this stream into a failed state.long
skip(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:
read
in classFilterInputStream
- Throws:
IOException
-
read
public int read(byte[] b) throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
skip
public long skip(long n) throws IOException
- Overrides:
skip
in classFilterInputStream
- Throws:
IOException
-
available
public int available() throws IOException
- Overrides:
available
in classFilterInputStream
- Throws:
IOException
-
reset
public void reset() throws IOException
- Overrides:
reset
in classFilterInputStream
- Throws:
IOException
-
setFailed
public void setFailed(Throwable cause)
Sets this stream into a failed state.- Parameters:
cause
- The cause of the failure.
-
-