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
Broken output stream. This stream always throws an
IOException from
all OutputStream methods.
This class is mostly useful for testing error handling in code that uses an output stream.
- Since:
- 2.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new stream that always throws anIOExceptionBrokenOutputStream(IOException exception) Creates a new stream that always throws the given exception. -
Method Summary
Methods inherited from class java.io.OutputStream
nullOutputStream, write, write
-
Constructor Details
-
BrokenOutputStream
Creates a new stream that always throws the given exception.- Parameters:
exception- the exception to be thrown
-
BrokenOutputStream
public BrokenOutputStream()Creates a new stream that always throws anIOException
-
-
Method Details
-
write
Throws the configured exception.- Specified by:
writein classOutputStream- Parameters:
b- ignored- Throws:
IOException- always thrown
-
flush
Throws the configured exception.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException- always thrown
-
close
Throws the configured exception.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- always thrown
-