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
Broken input stream. This stream always throws an
IOException
from
all the InputStream
methods where the exception is declared.
This class is mostly useful for testing error handling in code that uses an input stream.
- Since:
- 2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IOException
The exception that is thrown by all methods of this class. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new stream that always throws anIOException
BrokenInputStream
(IOException exception) Creates a new stream that always throws the given exception. -
Method Summary
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
exception
The exception that is thrown by all methods of this class.
-
-
Constructor Details
-
BrokenInputStream
Creates a new stream that always throws the given exception.- Parameters:
exception
- the exception to be thrown
-
BrokenInputStream
public BrokenInputStream()Creates a new stream that always throws anIOException
-
-
Method Details
-
read
Throws the configured exception.- Specified by:
read
in classInputStream
- Returns:
- nothing
- Throws:
IOException
- always thrown
-
available
Throws the configured exception.- Overrides:
available
in classInputStream
- Returns:
- nothing
- Throws:
IOException
- always thrown
-
skip
Throws the configured exception.- Overrides:
skip
in classInputStream
- Parameters:
n
- ignored- Returns:
- nothing
- Throws:
IOException
- always thrown
-
reset
Throws the configured exception.- Overrides:
reset
in classInputStream
- 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
-