public class BrokenReader
extends java.io.Reader
Reader methods where IOException is declared.
This class is mostly useful for testing error handling.
| Modifier and Type | Field and Description |
|---|---|
private java.util.function.Supplier<java.lang.Throwable> |
exceptionSupplier
A supplier for the exception that is thrown by all methods of this class.
|
static BrokenReader |
INSTANCE
A singleton instance using a default IOException.
|
| Constructor and Description |
|---|
BrokenReader()
Constructs a new reader that always throws an
IOException. |
BrokenReader(java.io.IOException exception)
Deprecated.
|
BrokenReader(java.util.function.Supplier<java.lang.Throwable> exceptionSupplier)
Constructs a new reader that always throws the supplied exception.
|
BrokenReader(java.lang.Throwable exception)
Constructs a new reader that always throws the given exception.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Throws the configured exception.
|
void |
mark(int readAheadLimit)
Throws the configured exception.
|
int |
read(char[] cbuf,
int off,
int len)
Throws the configured exception.
|
boolean |
ready()
Throws the configured exception.
|
void |
reset()
Throws the configured exception.
|
private java.lang.RuntimeException |
rethrow()
Throws the configured exception from its supplier.
|
long |
skip(long n)
Throws the configured exception.
|
public static final BrokenReader INSTANCE
private final java.util.function.Supplier<java.lang.Throwable> exceptionSupplier
public BrokenReader()
IOException.@Deprecated public BrokenReader(java.io.IOException exception)
BrokenReader(Throwable).exception - the exception to be thrown.public BrokenReader(java.util.function.Supplier<java.lang.Throwable> exceptionSupplier)
exceptionSupplier - a supplier for the IOException or RuntimeException to be thrown.public BrokenReader(java.lang.Throwable exception)
exception - the exception to be thrown.public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.Readerjava.io.IOException - always throws the exception configured in a constructor.public void mark(int readAheadLimit)
throws java.io.IOException
mark in class java.io.ReaderreadAheadLimit - ignored.java.io.IOException - always throws the exception configured in a constructor.public int read(char[] cbuf,
int off,
int len)
throws java.io.IOException
read in class java.io.Readercbuf - ignored.off - ignored.len - ignored.java.io.IOException - always throws the exception configured in a constructor.public boolean ready()
throws java.io.IOException
ready in class java.io.Readerjava.io.IOException - always throws the exception configured in a constructor.public void reset()
throws java.io.IOException
reset in class java.io.Readerjava.io.IOException - always throws the exception configured in a constructor.private java.lang.RuntimeException rethrow()
public long skip(long n)
throws java.io.IOException
skip in class java.io.Readern - ignored.java.io.IOException - always throws the exception configured in a constructor.