BrokenInputStream (Commons IO 2.5)
Date: 2016-12-01

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.InputStream

  Broken input stream. This stream always throws an `IOException` from all the `InputStream` methods where the exception is declared.

  This class is mostly useful for testing error handling in code that uses an input stream.

  Since:
    2.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private java.io.IOException` | `exception` The exception that is thrown by all methods of this class.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BrokenInputStream()` Creates a new stream that always throws an `IOException`
    `BrokenInputStream(java.io.IOException exception)` Creates a new stream that always throws the given exception.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `available()` Throws the configured exception.
    `void` | `close()` Throws the configured exception.
    `int` | `read()` Throws the configured exception.
    `void` | `reset()` Throws the configured exception.
    `long` | `skip(long n)` Throws the configured exception.

    - ### Methods inherited from class java.io.InputStream

      `mark, markSupported, read, read`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### exception

          private final java.io.IOException exception

      The exception that is thrown by all methods of this class.

  - ### 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 an `IOException`

  - ### Method Detail

    - #### read

          public int read()
                   throws java.io.IOException

      Throws the configured exception.
      Specified by:
        `read` in class `java.io.InputStream`
      Returns:
        nothing
      Throws:
        `java.io.IOException` - always thrown

    - #### available

          public int available()
                        throws java.io.IOException

      Throws the configured exception.
      Overrides:
        `available` in class `java.io.InputStream`
      Returns:
        nothing
      Throws:
        `java.io.IOException` - always thrown

    - #### skip

          public long skip(long n)
                    throws java.io.IOException

      Throws the configured exception.
      Overrides:
        `skip` in class `java.io.InputStream`
      Parameters:
        `n` - ignored
      Returns:
        nothing
      Throws:
        `java.io.IOException` - always thrown

    - #### reset

          public void reset()
                     throws java.io.IOException

      Throws the configured exception.
      Overrides:
        `reset` in class `java.io.InputStream`
      Throws:
        `java.io.IOException` - always thrown

    - #### close

          public void close()
                     throws java.io.IOException

      Throws the configured exception.
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Overrides:
        `close` in class `java.io.InputStream`
      Throws:
        `java.io.IOException` - always thrown

Copyright (c) 2002-2016 Apache Software Foundation