Class BrokenWriter

java.lang.Object
java.io.Writer
org.apache.commons.io.output.BrokenWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable

public class BrokenWriter extends Writer
Broken writer. This writer always throws an IOException from all Writer methods.

This class is mostly useful for testing error handling in code that uses a writer.

Since:
2.0
  • Field Details

    • exception

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

    • BrokenWriter

      public BrokenWriter(IOException exception)
      Creates a new writer that always throws the given exception.
      Parameters:
      exception - the exception to be thrown
    • BrokenWriter

      public BrokenWriter()
      Creates a new writer that always throws an IOException
  • Method Details