Package org.apache.commons.io.input
Class BrokenInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.io.input.BrokenInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
Always throws an
IOException from all the InputStream methods where the exception is declared.
This class is mostly useful for testing error handling.
- Since:
- 2.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new stream that always throws anIOException.BrokenInputStream(IOException exception) Constructs a new stream that always throws the given exception.BrokenInputStream(Supplier<IOException> exceptionSupplier) Constructs a new stream that always throws anIOException. -
Method Summary
Methods inherited from class java.io.InputStream
mark, markSupported, read, read
-
Field Details
-
INSTANCE
The singleton instance.- Since:
- 2.12.0
-
-
Constructor Details
-
BrokenInputStream
public BrokenInputStream()Constructs a new stream that always throws anIOException. -
BrokenInputStream
Constructs a new stream that always throws the given exception.- Parameters:
exception- the exception to be thrown.
-
BrokenInputStream
Constructs a new stream that always throws anIOException.- Parameters:
exceptionSupplier- a supplier for the exception to be thrown.- Since:
- 2.12.0
-
-
Method Details
-
available
Throws the configured exception.- Overrides:
availablein classInputStream- Returns:
- nothing
- Throws:
IOException- always thrown
-
close
Throws the configured exception.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException- always thrown
-
read
Throws the configured exception.- Specified by:
readin classInputStream- Returns:
- nothing
- Throws:
IOException- always thrown
-
reset
Throws the configured exception.- Overrides:
resetin classInputStream- Throws:
IOException- always thrown
-
skip
Throws the configured exception.- Overrides:
skipin classInputStream- Parameters:
n- ignored- Returns:
- nothing
- Throws:
IOException- always thrown
-