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.ReaderAlways throws an exception from allReadermethods whereIOExceptionis declared.This class is mostly useful for testing error handling.
- Since:
 - 2.7
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static BrokenReaderINSTANCEA singleton instance using a default IOException. 
- 
Constructor Summary
Constructors Constructor Description BrokenReader()Constructs a new reader that always throws anIOException.BrokenReader(java.io.IOException exception)Deprecated.BrokenReader(java.lang.Throwable exception)Constructs a new reader that always throws the given exception.BrokenReader(java.util.function.Supplier<java.lang.Throwable> exceptionSupplier)Constructs a new reader that always throws the supplied 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. 
 - 
 
- 
- 
Field Detail
- 
INSTANCE
public static final BrokenReader INSTANCE
A singleton instance using a default IOException.- Since:
 - 2.12.0
 
 
 - 
 
- 
Constructor Detail
- 
BrokenReader
public BrokenReader()
Constructs a new reader that always throws anIOException. 
- 
BrokenReader
@Deprecated public BrokenReader(java.io.IOException exception)
Deprecated.Constructs a new reader that always throws the given exception.- Parameters:
 exception- the exception to be thrown.
 
- 
BrokenReader
public BrokenReader(java.util.function.Supplier<java.lang.Throwable> exceptionSupplier)
Constructs 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
 
 
- 
BrokenReader
public BrokenReader(java.lang.Throwable exception)
Constructs a new reader that always throws the given exception.- Parameters:
 exception- the exception to be thrown.- Since:
 - 2.16.0
 
 
 - 
 
- 
Method Detail
- 
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 throws the exception configured in a constructor.
 
- 
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 throws the exception configured in a constructor.
 
- 
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- ignored.off- ignored.len- ignored.- Returns:
 - nothing.
 - Throws:
 java.io.IOException- always throws the exception configured in a constructor.
 
- 
ready
public boolean ready() throws java.io.IOExceptionThrows the configured exception.- Overrides:
 readyin classjava.io.Reader- Returns:
 - nothing.
 - Throws:
 java.io.IOException- always throws the exception configured in a constructor.
 
- 
reset
public void reset() throws java.io.IOExceptionThrows the configured exception.- Overrides:
 resetin classjava.io.Reader- Throws:
 java.io.IOException- always throws the exception configured in a constructor.
 
- 
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 throws the exception configured in a constructor.
 
 - 
 
 -