public class BrokenReader extends Reader
IOException from all the Reader methods where the exception is declared.
This class is mostly useful for testing error handling.
| Modifier and Type | Field and Description |
|---|---|
static BrokenReader |
INSTANCE
A singleton instance using a default IOException.
|
| Constructor and Description |
|---|
BrokenReader()
Creates a new reader that always throws an
IOException. |
BrokenReader(IOException exception)
Creates a new reader that always throws the given exception.
|
BrokenReader(Supplier<IOException> exceptionSupplier)
Creates a new reader that always throws an
IOException |
| 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.
|
long |
skip(long n)
Throws the configured exception.
|
markSupported, read, read, readpublic static final BrokenReader INSTANCE
public BrokenReader()
IOException.public BrokenReader(IOException exception)
exception - the exception to be thrown.public BrokenReader(Supplier<IOException> exceptionSupplier)
IOExceptionexceptionSupplier - a supplier for the exception to be thrown.public void close() throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class ReaderIOException - always thrownpublic void mark(int readAheadLimit) throws IOException
mark in class ReaderreadAheadLimit - ignoredIOException - always thrownpublic int read(char[] cbuf, int off, int len) throws IOException
read in class Readercbuf - ignoredoff - ignoredlen - ignoredIOException - always thrownpublic boolean ready() throws IOException
ready in class ReaderIOException - always thrownpublic void reset() throws IOException
reset in class ReaderIOException - always thrownpublic long skip(long n) throws IOException
skip in class Readern - ignoredIOException - always thrownCopyright © 2002–2023 The Apache Software Foundation. All rights reserved.