Package org.apache.commons.io.input
Class BrokenReader
- java.lang.Object
-
- java.io.Reader
-
- org.apache.commons.io.input.BrokenReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Readable
public class BrokenReader extends java.io.ReaderBroken reader. This reader always throws anIOExceptionfrom all theReadermethods where the exception is declared.This class is mostly useful for testing error handling in code that uses a reader.
- Since:
- 2.7
-
-
Constructor Summary
Constructors Constructor Description BrokenReader()Creates a new reader that always throws anIOExceptionBrokenReader(java.io.IOException exception)Creates a new reader that always throws the given exception.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()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.
-
-
-
Method Detail
-
read
public int read(char[] cbuf, int off, int len) throws java.io.IOExceptionThrows the configured exception.- Specified by:
readin classjava.io.Reader- Parameters:
cbuf- ignoredoff- ignoredlen- ignored- Returns:
- nothing
- Throws:
java.io.IOException- always thrown
-
skip
public long skip(long n) throws java.io.IOExceptionThrows the configured exception.- Overrides:
skipin classjava.io.Reader- Parameters:
n- ignored- Returns:
- nothing
- Throws:
java.io.IOException- always thrown
-
ready
public boolean ready() throws java.io.IOExceptionThrows the configured exception.- Overrides:
readyin classjava.io.Reader- Returns:
- nothing
- Throws:
java.io.IOException- always thrown
-
mark
public void mark(int readAheadLimit) throws java.io.IOExceptionThrows the configured exception.- Overrides:
markin classjava.io.Reader- Parameters:
readAheadLimit- ignored- Throws:
java.io.IOException- always thrown
-
reset
public void reset() throws java.io.IOExceptionThrows the configured exception.- Overrides:
resetin classjava.io.Reader- Throws:
java.io.IOException- always thrown
-
close
public void close() throws java.io.IOExceptionThrows the configured exception.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classjava.io.Reader- Throws:
java.io.IOException- always thrown
-
-