Package org.apache.commons.io.output
Class BrokenWriter
- java.lang.Object
-
- java.io.Writer
-
- org.apache.commons.io.output.BrokenWriter
-
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
public class BrokenWriter extends Writer
Broken writer. This writer always throws anIOExceptionfrom allWritermethods.This class is mostly useful for testing error handling in code that uses a writer.
- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description BrokenWriter()Creates a new writer that always throws anIOExceptionBrokenWriter(IOException exception)Creates a new writer that always throws the given exception.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Throws the configured exception.voidflush()Throws the configured exception.voidwrite(char[] cbuf, int off, int len)Throws the configured exception.
-
-
-
Constructor Detail
-
BrokenWriter
public BrokenWriter(IOException exception)
Creates a new writer that always throws the given exception.- Parameters:
exception- the exception to be thrown
-
BrokenWriter
public BrokenWriter()
Creates a new writer that always throws anIOException
-
-
Method Detail
-
write
public void write(char[] cbuf, int off, int len) throws IOExceptionThrows the configured exception.- Specified by:
writein classWriter- Parameters:
cbuf- ignoredoff- ignoredlen- ignored- Throws:
IOException- always thrown
-
flush
public void flush() throws IOExceptionThrows the configured exception.- Specified by:
flushin interfaceFlushable- Specified by:
flushin classWriter- Throws:
IOException- always thrown
-
close
public void close() throws IOExceptionThrows the configured exception.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException- always thrown
-
-