Package org.apache.commons.io.input
Class BrokenInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.commons.io.input.BrokenInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class BrokenInputStream extends java.io.InputStreamBroken input stream. This stream always throws anIOExceptionfrom all theInputStreammethods where the exception is declared.This class is mostly useful for testing error handling in code that uses an input stream.
- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description BrokenInputStream()Creates a new stream that always throws anIOExceptionBrokenInputStream(java.io.IOException exception)Creates a new stream that always throws the given exception.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()Throws the configured exception.voidclose()Throws the configured exception.intread()Throws the configured exception.voidreset()Throws the configured exception.longskip(long n)Throws the configured exception.
-
-
-
Constructor Detail
-
BrokenInputStream
public BrokenInputStream(java.io.IOException exception)
Creates a new stream that always throws the given exception.- Parameters:
exception- the exception to be thrown
-
BrokenInputStream
public BrokenInputStream()
Creates a new stream that always throws anIOException
-
-
Method Detail
-
read
public int read() throws java.io.IOExceptionThrows the configured exception.- Specified by:
readin classjava.io.InputStream- Returns:
- nothing
- Throws:
java.io.IOException- always thrown
-
available
public int available() throws java.io.IOExceptionThrows the configured exception.- Overrides:
availablein classjava.io.InputStream- Returns:
- nothing
- Throws:
java.io.IOException- always thrown
-
skip
public long skip(long n) throws java.io.IOExceptionThrows the configured exception.- Overrides:
skipin classjava.io.InputStream- Parameters:
n- ignored- Returns:
- nothing
- Throws:
java.io.IOException- always thrown
-
reset
public void reset() throws java.io.IOExceptionThrows the configured exception.- Overrides:
resetin classjava.io.InputStream- Throws:
java.io.IOException- always thrown
-
close
public void close() throws java.io.IOExceptionThrows the configured exception.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException- always thrown
-
-