Package org.apache.commons.io.output
Class BrokenOutputStream
java.lang.Object
java.io.OutputStream
org.apache.commons.io.output.BrokenOutputStream
- All Implemented Interfaces:
- Closeable,- Flushable,- AutoCloseable
Always throws an exception from all 
OutputStream methods where IOException is declared.
 This class is mostly useful for testing error handling.
- Since:
- 2.0
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final BrokenOutputStreamThe singleton instance using a default IOException.
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a new stream that always throws anIOException.BrokenOutputStream(IOException exception) Deprecated.BrokenOutputStream(Throwable exception) Constructs a new stream that always throws the given exception.BrokenOutputStream(Function<String, Throwable> exceptionFunction) Constructs a new stream that always throws the supplied exception.BrokenOutputStream(Supplier<Throwable> exceptionSupplier) Deprecated.
- 
Method SummaryMethods inherited from class java.io.OutputStreamwrite, write
- 
Field Details- 
INSTANCEThe singleton instance using a default IOException.- Since:
- 2.12.0
 
 
- 
- 
Constructor Details- 
BrokenOutputStreampublic BrokenOutputStream()Constructs a new stream that always throws anIOException.
- 
BrokenOutputStreamConstructs a new stream that always throws the supplied exception.This class uses the invoked method name as the function input. - Parameters:
- exceptionFunction- a supplier for the IOException or RuntimeException to be thrown.
- Since:
- 2.19.0
 
- 
BrokenOutputStreamDeprecated.Constructs a new stream that always throws the given exception.- Parameters:
- exception- the exception to be thrown.
 
- 
BrokenOutputStreamDeprecated.Constructs a new stream that always throws the supplied exception.- Parameters:
- exceptionSupplier- a supplier for the IOException or RuntimeException to be thrown.
- Since:
- 2.12.0
 
- 
BrokenOutputStreamConstructs a new stream 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
- Overrides:
- closein class- OutputStream
- Throws:
- IOException- always throws the exception configured in a constructor.
 
- 
flushThrows the configured exception.- Specified by:
- flushin interface- Flushable
- Overrides:
- flushin class- OutputStream
- Throws:
- IOException- always throws the exception configured in a constructor.
 
- 
writeThrows the configured exception.- Specified by:
- writein class- OutputStream
- Parameters:
- b- ignored.
- Throws:
- IOException- always throws the exception configured in a constructor.
 
 
- 
BrokenOutputStream(Throwable).