public class BrokenWriter extends Writer
IOException from all Writer methods.
This class is mostly useful for testing error handling in code that uses a writer.
| Modifier and Type | Field and Description |
|---|---|
static BrokenWriter |
INSTANCE
The singleton instance.
|
| Constructor and Description |
|---|
BrokenWriter()
Creates a new writer that always throws an
IOException. |
BrokenWriter(IOException exception)
Creates a new writer that always throws the given exception.
|
BrokenWriter(Supplier<IOException> exceptionSupplier)
Creates a new writer that always throws an
IOException. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Throws the configured exception.
|
void |
flush()
Throws the configured exception.
|
void |
write(char[] cbuf,
int off,
int len)
Throws the configured exception.
|
public static final BrokenWriter INSTANCE
public BrokenWriter()
IOException.public BrokenWriter(IOException exception)
exception - the exception to be thrown.public BrokenWriter(Supplier<IOException> exceptionSupplier)
IOException.exceptionSupplier - a supplier for the exception to be thrown.public void close() throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class WriterIOException - always thrownpublic void flush() throws IOException
flush in interface Flushableflush in class WriterIOException - always thrownpublic void write(char[] cbuf, int off, int len) throws IOException
write in class Writercbuf - ignoredoff - ignoredlen - ignoredIOException - always thrownCopyright © 2002–2023 The Apache Software Foundation. All rights reserved.