Package org.apache.commons.io.input

# Class CircularInputStream

java.lang.Object
java.io.InputStream
org.apache.commons.io.input.AbstractInputStream
org.apache.commons.io.input.CircularInputStream

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

Direct Known Subclasses:
  `InfiniteCircularInputStream`

public class CircularInputStream extends AbstractInputStream
An `InputStream` that repeats provided bytes for given target byte count.

Closing this input stream has no effect. The methods in this class can be called after the stream has been closed without generating an `IOException`.

Since:
  2.8.0
See Also:
  - `InfiniteCircularInputStream`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CircularInputStream(byte[] repeatContent, long targetByteCount)`
  Constructs an instance from the specified array of bytes.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `available()`
  `void`
  `close()`
  `int`
  `read()`

  ### Methods inherited from class org.apache.commons.io.input.AbstractInputStream

  `isClosed, setClosed`

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

  `mark, markSupported, read, read, reset, skip`

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

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

- ## Constructor Details

  - ### CircularInputStream

    public CircularInputStream(byte[] repeatContent, long targetByteCount)
    Constructs an instance from the specified array of bytes.
    Parameters:
      `repeatContent` - Input buffer to be repeated this buffer is not copied.
      `targetByteCount` - How many bytes the read. A negative number means an infinite target count.

- ## Method Details

  - ### available

    public int available() throws IOException
    Overrides:
      `available` in class `InputStream`
    Throws:
      `IOException`

  - ### close

    public void close() throws IOException
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Overrides:
      `close` in class `AbstractInputStream`
    Throws:
      `IOException`

  - ### read

    public int read()
    Specified by:
      `read` in class `InputStream`