public class BrokenInputStream extends InputStream
InputStream methods where IOException is declared.
This class is mostly useful for testing error handling.
| Modifier and Type | Field and Description |
|---|---|
static BrokenInputStream |
INSTANCE
The singleton instance using a default IOException.
|
| Constructor and Description |
|---|
BrokenInputStream()
Constructs a new stream that always throws an
IOException. |
BrokenInputStream(java.util.function.Supplier<Throwable> exceptionSupplier)
Constructs a new stream that always throws the supplied exception.
|
BrokenInputStream(Throwable exception)
Constructs a new stream that always throws the given exception.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Throws the configured exception.
|
void |
close()
Throws the configured exception.
|
(package private) Throwable |
getThrowable()
Gets the Throwable to throw.
|
int |
read()
Throws the configured exception.
|
void |
reset()
Throws the configured exception.
|
long |
skip(long n)
Throws the configured exception.
|
mark, markSupported, read, readpublic static final BrokenInputStream INSTANCE
public BrokenInputStream()
IOException.public BrokenInputStream(java.util.function.Supplier<Throwable> exceptionSupplier)
exceptionSupplier - a supplier for the IOException or RuntimeException to be thrown.public BrokenInputStream(Throwable exception)
exception - the exception to be thrown.public int available()
throws IOException
available in class InputStreamIOException - always throws the exception configured in a constructor.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOException - always throws the exception configured in a constructor.Throwable getThrowable()
public int read()
throws IOException
read in class InputStreamIOException - always throws the exception configured in a constructor.public void reset()
throws IOException
reset in class InputStreamIOException - always throws the exception configured in a constructor.public long skip(long n)
throws IOException
skip in class InputStreamn - ignored.IOException - always throws the exception configured in a constructor.