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
FieldsModifier and TypeFieldDescriptionprivate final Supplier
<IOException> A supplier for the exception that is thrown by all methods of this class.static final BrokenInputStream
The singleton instance. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new stream that always throws anIOException
.BrokenInputStream
(IOException exception) Creates a new stream that always throws the given exception.BrokenInputStream
(Supplier<IOException> exceptionSupplier) Creates 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
-
exceptionSupplier
A supplier for the exception that is thrown by all methods of this class.
-
-
Constructor Details
-
BrokenInputStream
public BrokenInputStream()Creates a new stream that always throws anIOException
. -
BrokenInputStream
Creates a new stream that always throws the given exception.- Parameters:
exception
- the exception to be thrown.
-
BrokenInputStream
Creates 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:
available
in classInputStream
- Returns:
- nothing
- Throws:
IOException
- always thrown
-
close
Throws the configured exception.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
- always thrown
-
read
Throws the configured exception.- Specified by:
read
in classInputStream
- Returns:
- nothing
- Throws:
IOException
- always thrown
-
reset
Throws the configured exception.- Overrides:
reset
in classInputStream
- Throws:
IOException
- always thrown
-
skip
Throws the configured exception.- Overrides:
skip
in classInputStream
- Parameters:
n
- ignored- Returns:
- nothing
- Throws:
IOException
- always thrown
-