Package org.apache.commons.io.input
Class BrokenInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.io.input.BrokenInputStream
- All Implemented Interfaces:
- Closeable,- AutoCloseable
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 SummaryFieldsModifier and TypeFieldDescriptionstatic final BrokenInputStreamThe singleton instance using a default IOException.
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a new stream that always throws anIOException.BrokenInputStream(IOException exception) Deprecated.BrokenInputStream(Throwable exception) Constructs a new stream that always throws the given exception.BrokenInputStream(Supplier<Throwable> exceptionSupplier) Constructs a new stream that always throws the supplied exception.
- 
Method SummaryMethods inherited from class java.io.InputStreammark, markSupported, read, read
- 
Field Details- 
INSTANCEThe singleton instance using a default IOException.- Since:
- 2.12.0
 
 
- 
- 
Constructor Details- 
BrokenInputStreampublic BrokenInputStream()Constructs a new stream that always throws anIOException.
- 
BrokenInputStreamDeprecated.Constructs a new stream that always throws the given exception.- Parameters:
- exception- the exception to be thrown.
 
- 
BrokenInputStreamConstructs 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
 
- 
BrokenInputStreamConstructs a new stream that always throws the given exception.- Parameters:
- exception- the exception to be thrown.
- Since:
- 2.16.0
 
 
- 
- 
Method Details- 
availableThrows the configured exception.- Overrides:
- availablein class- InputStream
- Returns:
- nothing.
- Throws:
- IOException- always throws the exception configured in a constructor.
 
- 
closeThrows the configured exception.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- InputStream
- Throws:
- IOException- always throws the exception configured in a constructor.
 
- 
readThrows the configured exception.- Specified by:
- readin class- InputStream
- Returns:
- nothing.
- Throws:
- IOException- always throws the exception configured in a constructor.
 
- 
resetThrows the configured exception.- Overrides:
- resetin class- InputStream
- Throws:
- IOException- always throws the exception configured in a constructor.
 
- 
skipThrows the configured exception.- Overrides:
- skipin class- InputStream
- Parameters:
- n- ignored.
- Returns:
- nothing.
- Throws:
- IOException- always throws the exception configured in a constructor.
 
 
- 
BrokenInputStream(Throwable).