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
Always throws an exception from all 
Reader methods where IOException is declared.
 This class is mostly useful for testing error handling.
- Since:
- 2.7
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final BrokenReaderA singleton instance using a default IOException.
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a new reader that always throws anIOException.BrokenReader(IOException exception) Deprecated.BrokenReader(Throwable exception) Constructs a new reader that always throws the given exception.BrokenReader(Supplier<Throwable> exceptionSupplier) Constructs a new reader that always throws the supplied exception.
- 
Method SummaryModifier 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.ReadermarkSupported, read, read, read
- 
Field Details- 
INSTANCEA singleton instance using a default IOException.- Since:
- 2.12.0
 
 
- 
- 
Constructor Details- 
BrokenReaderpublic BrokenReader()Constructs a new reader that always throws anIOException.
- 
BrokenReaderDeprecated.Constructs a new reader that always throws the given exception.- Parameters:
- exception- the exception to be thrown.
 
- 
BrokenReaderConstructs a new reader that always throws the supplied exception.- Parameters:
- exceptionSupplier- a supplier for the IOException or RuntimeException to be thrown.
- Since:
- 2.12.0
 
- 
BrokenReaderConstructs a new reader that always throws the given exception.- Parameters:
- exception- the exception to be thrown.
- Since:
- 2.16.0
 
 
- 
- 
Method Details- 
closeThrows the configured exception.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein class- Reader
- Throws:
- IOException- always throws the exception configured in a constructor.
 
- 
markThrows the configured exception.- Overrides:
- markin class- Reader
- Parameters:
- readAheadLimit- ignored.
- Throws:
- IOException- always throws the exception configured in a constructor.
 
- 
readThrows the configured exception.- Specified by:
- readin class- Reader
- Parameters:
- cbuf- ignored.
- off- ignored.
- len- ignored.
- Returns:
- nothing.
- Throws:
- IOException- always throws the exception configured in a constructor.
 
- 
readyThrows the configured exception.- Overrides:
- readyin class- Reader
- Returns:
- nothing.
- Throws:
- IOException- always throws the exception configured in a constructor.
 
- 
resetThrows the configured exception.- Overrides:
- resetin class- Reader
- Throws:
- IOException- always throws the exception configured in a constructor.
 
- 
skipThrows the configured exception.- Overrides:
- skipin class- Reader
- Parameters:
- n- ignored.
- Returns:
- nothing.
- Throws:
- IOException- always throws the exception configured in a constructor.
 
 
- 
BrokenReader(Throwable).