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 |
---|---|
private java.io.IOException |
exception
The exception that is thrown by all methods of this class.
|
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.
|
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.
|
private final java.io.IOException exception
public BrokenWriter(java.io.IOException exception)
exception
- the exception to be thrownpublic BrokenWriter()
IOException
public 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 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 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 thrown