Package org.apache.commons.io.input
Class BrokenReader
java.lang.Object
java.io.Reader
org.apache.commons.io.input.BrokenReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
Broken reader. This reader always throws an
IOException from
all the Reader methods where the exception is declared.
This class is mostly useful for testing error handling in code that uses a reader.
- Since:
- 2.7
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new reader that always throws anIOExceptionBrokenReader(IOException exception) Creates a new reader that always throws the given exception. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Throws the configured exception.voidmark(int readAheadLimit) Throws the configured exception.intread(char[] cbuf, int off, int len) Throws the configured exception.booleanready()Throws the configured exception.voidreset()Throws the configured exception.longskip(long n) Throws the configured exception.Methods inherited from class java.io.Reader
markSupported, nullReader, read, read, read, transferTo
-
Constructor Details
-
BrokenReader
Creates a new reader that always throws the given exception.- Parameters:
exception- the exception to be thrown
-
BrokenReader
public BrokenReader()Creates a new reader that always throws anIOException
-
-
Method Details
-
read
Throws the configured exception.- Specified by:
readin classReader- Parameters:
cbuf- ignoredoff- ignoredlen- ignored- Returns:
- nothing
- Throws:
IOException- always thrown
-
skip
Throws the configured exception.- Overrides:
skipin classReader- Parameters:
n- ignored- Returns:
- nothing
- Throws:
IOException- always thrown
-
ready
Throws the configured exception.- Overrides:
readyin classReader- Returns:
- nothing
- Throws:
IOException- always thrown
-
mark
Throws the configured exception.- Overrides:
markin classReader- Parameters:
readAheadLimit- ignored- Throws:
IOException- always thrown
-
reset
Throws the configured exception.- Overrides:
resetin classReader- Throws:
IOException- always thrown
-
close
Throws the configured exception.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException- always thrown
-