Package org.apache.commons.io.output
Class BrokenOutputStream
- java.lang.Object
 - 
- java.io.OutputStream
 - 
- org.apache.commons.io.output.BrokenOutputStream
 
 
 
- 
- All Implemented Interfaces:
 java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class BrokenOutputStream extends java.io.OutputStreamBroken output stream. This stream always throws anIOExceptionfrom allOutputStreammethods.This class is mostly useful for testing error handling in code that uses an output stream.
- Since:
 - 2.0
 
 
- 
- 
Constructor Summary
Constructors Constructor Description BrokenOutputStream()Creates a new stream that always throws anIOExceptionBrokenOutputStream(java.io.IOException exception)Creates a new stream 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(int b)Throws the configured exception. 
 - 
 
- 
- 
Constructor Detail
- 
BrokenOutputStream
public BrokenOutputStream(java.io.IOException exception)
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 Detail
- 
write
public void write(int b) throws java.io.IOExceptionThrows the configured exception.- Specified by:
 writein classjava.io.OutputStream- Parameters:
 b- ignored- Throws:
 java.io.IOException- always thrown
 
- 
flush
public void flush() throws java.io.IOExceptionThrows the configured exception.- Specified by:
 flushin interfacejava.io.Flushable- Overrides:
 flushin classjava.io.OutputStream- Throws:
 java.io.IOException- always thrown
 
- 
close
public void close() throws java.io.IOExceptionThrows the configured exception.- Specified by:
 closein interfacejava.lang.AutoCloseable- Specified by:
 closein interfacejava.io.Closeable- Overrides:
 closein classjava.io.OutputStream- Throws:
 java.io.IOException- always thrown
 
 - 
 
 -