Class BrokenReader

java.lang.Object
java.io.Reader
org.apache.commons.io.input.BrokenReader
All Implemented Interfaces:
Closeable, AutoCloseable, Readable

public class BrokenReader extends Reader
Always throws an IOException from all the Reader methods where the exception is declared.

This class is mostly useful for testing error handling.

Since:
2.7
  • Field Details

    • INSTANCE

      public static final BrokenReader INSTANCE
      A singleton instance using a default IOException.
      Since:
      2.12.0
  • Constructor Details

    • BrokenReader

      public BrokenReader()
      Constructs a new reader that always throws an IOException.
    • BrokenReader

      public BrokenReader(IOException exception)
      Constructs a new reader that always throws the given exception.
      Parameters:
      exception - the exception to be thrown.
    • BrokenReader

      public BrokenReader(Supplier<IOException> exceptionSupplier)
      Constructs a new reader that always throws an IOException
      Parameters:
      exceptionSupplier - a supplier for the exception to be thrown.
      Since:
      2.12.0
  • Method Details