Module org.hsqldb
Package org.hsqldb.lib

## Class CountdownInputStream

- java.lang.Object
- - java.io.InputStream
  - - org.hsqldb.lib.CountdownInputStream

- All Implemented Interfaces:
    `java.io.Closeable`, `java.lang.AutoCloseable`

      public final class CountdownInputStream
      extends java.io.InputStream

  Counts down from a specified value the number of bytes actually read from the wrapped InputStream.

  Returns minus one (-1) early from readXXX methods if the count down reaches zero (0) before the end of the wrapped InputStream is encountered.

  This class is especially useful when a fixed number of bytes is to be read from an InputStream that is in turn to be used as the source for an `InputStreamReader`.

  Since:
    1.9.0
  Author:
    Campbell Burnet (campbell-burnet@users dot sourceforge.net)

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CountdownInputStream​(java.io.InputStream is)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `int` | `available()` |
    `void` | `close()` |
    `long` | `getCount()` |
    `int` | `read()` |
    `int` | `read​(byte[] buf)` |
    `int` | `read​(byte[] buf, int off, int len)` |
    `void` | `setCount​(long count)` |
    `long` | `skip​(long count)` |

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

      `mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, transferTo`

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

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

- - ### Constructor Detail

    - #### CountdownInputStream

          public CountdownInputStream​(java.io.InputStream is)

  - ### Method Detail

    - #### read

          public int read()
                   throws java.io.IOException

      Specified by:
        `read` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`

    - #### read

          public int read​(byte[] buf)
                   throws java.io.IOException

      Overrides:
        `read` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`

    - #### read

          public int read​(byte[] buf,
                          int off,
                          int len)
                   throws java.io.IOException

      Overrides:
        `read` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`

    - #### close

          public void close()
                     throws java.io.IOException

      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Specified by:
        `close` in interface `java.io.Closeable`
      Overrides:
        `close` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`

    - #### available

          public int available()
                        throws java.io.IOException

      Overrides:
        `available` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`

    - #### skip

          public long skip​(long count)
                    throws java.io.IOException

      Overrides:
        `skip` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`

    - #### getCount

          public long getCount()

    - #### setCount

          public void setCount​(long count)