public class BrokenWriter
extends java.io.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(java.io.IOException exception)
Creates a new writer that always throws the given exception.
|
BrokenWriter(java.util.function.Supplier<java.io.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(java.io.IOException exception)
exception
- the exception to be thrown.public BrokenWriter(java.util.function.Supplier<java.io.IOException> exceptionSupplier)
IOException
.exceptionSupplier
- a supplier for the exception to be thrown.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.Writer
java.io.IOException
- always thrownpublic void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.Writer
java.io.IOException
- always thrownpublic void write(char[] cbuf, int off, int len) throws java.io.IOException
write
in class java.io.Writer
cbuf
- ignoredoff
- ignoredlen
- ignoredjava.io.IOException
- always thrownCopyright © 2010 - 2023 Adobe. All Rights Reserved