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
Always throws an exception from all 
Writer methods where IOException is declared.
 This class is mostly useful for testing error handling.
- Since:
- 2.0
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final BrokenWriterThe singleton instance using a default IOException.
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a new writer that always throws anIOException.BrokenWriter(IOException exception) Deprecated.BrokenWriter(Throwable exception) Constructs a new writer that always throws the given exception.BrokenWriter(Supplier<Throwable> exceptionSupplier) Constructs a new writer that always throws the supplied exception.
- 
Method Summary
- 
Field Details- 
INSTANCEThe singleton instance using a default IOException.- Since:
- 2.12.0
 
 
- 
- 
Constructor Details- 
BrokenWriterpublic BrokenWriter()Constructs a new writer that always throws anIOException.
- 
BrokenWriterDeprecated.Constructs a new writer that always throws the given exception.- Parameters:
- exception- the exception to be thrown.
 
- 
BrokenWriterConstructs a new writer that always throws the supplied exception.- Parameters:
- exceptionSupplier- a supplier for the IOException or RuntimeException to be thrown.
- Since:
- 2.12.0
 
- 
BrokenWriterConstructs a new writer that always throws the given exception.- Parameters:
- exception- the exception to be thrown.
- Since:
- 2.16.0
 
 
- 
- 
Method Details- 
closeThrows the configured exception.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein class- Writer
- Throws:
- IOException- always throws the exception configured in a constructor.
 
- 
flushThrows the configured exception.- Specified by:
- flushin interface- Flushable
- Specified by:
- flushin class- Writer
- Throws:
- IOException- always throws the exception configured in a constructor.
 
- 
writeThrows the configured exception.- Specified by:
- writein class- Writer
- Parameters:
- cbuf- ignored.
- off- ignored.
- len- ignored.
- Throws:
- IOException- always throws the exception configured in a constructor.
 
 
- 
BrokenWriter(Throwable).