Package org.apache.commons.io.input
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
Broken reader. This reader always throws anIOException
from all theReader
methods where the exception is declared.This class is mostly useful for testing error handling in code that uses a reader.
- Since:
- 2.7
-
-
Constructor Summary
Constructors Constructor Description BrokenReader()
Creates a new reader that always throws anIOException
BrokenReader(IOException exception)
Creates a new reader that always throws the given exception.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Throws the configured exception.void
mark(int readAheadLimit)
Throws the configured exception.int
read(char[] cbuf, int off, int len)
Throws the configured exception.boolean
ready()
Throws the configured exception.void
reset()
Throws the configured exception.long
skip(long n)
Throws the configured exception.-
Methods inherited from class java.io.Reader
markSupported, nullReader, read, read, read, transferTo
-
-
-
-
Constructor Detail
-
BrokenReader
public BrokenReader(IOException exception)
Creates a new reader that always throws the given exception.- Parameters:
exception
- the exception to be thrown
-
BrokenReader
public BrokenReader()
Creates a new reader that always throws anIOException
-
-
Method Detail
-
read
public int read(char[] cbuf, int off, int len) throws IOException
Throws the configured exception.- Specified by:
read
in classReader
- Parameters:
cbuf
- ignoredoff
- ignoredlen
- ignored- Returns:
- nothing
- Throws:
IOException
- always thrown
-
skip
public long skip(long n) throws IOException
Throws the configured exception.- Overrides:
skip
in classReader
- Parameters:
n
- ignored- Returns:
- nothing
- Throws:
IOException
- always thrown
-
ready
public boolean ready() throws IOException
Throws the configured exception.- Overrides:
ready
in classReader
- Returns:
- nothing
- Throws:
IOException
- always thrown
-
mark
public void mark(int readAheadLimit) throws IOException
Throws the configured exception.- Overrides:
mark
in classReader
- Parameters:
readAheadLimit
- ignored- Throws:
IOException
- always thrown
-
reset
public void reset() throws IOException
Throws the configured exception.- Overrides:
reset
in classReader
- Throws:
IOException
- always thrown
-
close
public void close() throws IOException
Throws the configured exception.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
- always thrown
-
-