Class BrokenInputStream

java.lang.Object
java.io.InputStream
org.apache.commons.io.input.BrokenInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class BrokenInputStream extends InputStream
Always throws an exception from all InputStream methods where IOException is declared.

This class is mostly useful for testing error handling.

Since:
2.0
  • Field Details

    • INSTANCE

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

    • BrokenInputStream

      Constructs a new stream that always throws an IOException.
    • BrokenInputStream

      Constructs a new stream that always throws the given exception.
      Parameters:
      exception - the exception to be thrown.
    • BrokenInputStream

      public BrokenInputStream(Supplier<Throwable> exceptionSupplier)
      Constructs a new stream that always throws the supplied exception.
      Parameters:
      exceptionSupplier - a supplier for the IOException or RuntimeException to be thrown.
      Since:
      2.12.0
    • BrokenInputStream

      public BrokenInputStream(Throwable exception)
      Constructs a new stream that always throws the given exception.
      Parameters:
      exception - the exception to be thrown.
      Since:
      2.16.0
  • Method Details