Class BrokenOutputStream

java.lang.Object
java.io.OutputStream
org.apache.commons.io.output.BrokenOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class BrokenOutputStream extends OutputStream
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
  • Field Details

    • exception

      private final IOException exception
      The exception that is thrown by all methods of this class.
  • Constructor Details

    • BrokenOutputStream

      public BrokenOutputStream(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 an IOException
  • Method Details