Package org.apache.solr.common.util

## Class ResumableInputStream

- java.lang.Object
- - java.io.InputStream
  - - org.apache.solr.common.util.ResumableInputStream

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

    public class ResumableInputStream
    extends InputStream

An `InputStream` that can be resumed when the connection that is driving the input is interrupted.

### Constructor Summary

Constructors
`ResumableInputStream​(InputStream delegate, Function<Long,​InputStream> nextInputStreamSupplier)` Create a new ResumableInputStream

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `available()`
`void` `close()`
`void` `mark​(int readlimit)`
`boolean` `markSupported()`
`int` `read()` If an IOException is thrown by the delegate while reading, the delegate will be recreated and the read will be retried once during this read call.
`int` `read​(boolean isRetry)`
`int` `read​(byte[] b, int off, int len)` If an IOException is thrown by the delegate while reading, the delegate will be recreated and the read will be retried once during this read call.
`int` `read​(byte[] b, int off, int len, boolean isRetry)`
`void` `reset()`
`long` `skip​(long n)` If an IOException is thrown by the delegate while skipping, the delegate will be recreated from the position being skipped to and the return value will be `n`.

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

`nullInputStream, read, readAllBytes, readNBytes, readNBytes, transferTo`

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

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

### Constructor Detail

#### ResumableInputStream

    public ResumableInputStream​(InputStream delegate,
                                Function<Long,​InputStream> nextInputStreamSupplier)

Create a new ResumableInputStream

Parameters:
  `delegate` - The original `InputStream` that will be used as a delegate
  `nextInputStreamSupplier` - A function to create the next InputStream given the number of bytes already read. These inputs can, for example, be used to populate the HTTP Range header. If an unsupported input is provided (more bytes than exist), then a `null` `InputStream` should be returned.

### Method Detail

#### read

    public int read()
             throws IOException

If an IOException is thrown by the delegate while reading, the delegate will be recreated and the read will be retried once during this read call.

Specified by:
  `read` in class `InputStream`
Throws:
  `IOException`

#### read

    public int read​(boolean isRetry)
             throws IOException

Throws:
  `IOException`

#### read

    public int read​(byte[] b,
                    int off,
                    int len)
             throws IOException

If an IOException is thrown by the delegate while reading, the delegate will be recreated and the read will be retried once during this read call.

Overrides:
  `read` in class `InputStream`
Throws:
  `IOException`

#### read

    public int read​(byte[] b,
                    int off,
                    int len,
                    boolean isRetry)
             throws IOException

Throws:
  `IOException`

#### skip

    public long skip​(long n)
              throws IOException

If an IOException is thrown by the delegate while skipping, the delegate will be recreated from the position being skipped to and the return value will be `n`. This may be longer than the remaining number of bytes, and if so the delegate will be set to a NullInputStream.

Overrides:
  `skip` in class `InputStream`
Throws:
  `IOException`

#### markSupported

    public boolean markSupported()

Overrides:
  `markSupported` in class `InputStream`

#### mark

    public void mark​(int readlimit)

Overrides:
  `mark` in class `InputStream`

#### available

    public int available()
                  throws IOException

Overrides:
  `available` in class `InputStream`
Throws:
  `IOException`

#### reset

    public void reset()

Overrides:
  `reset` in class `InputStream`

#### close

    public void close()
               throws IOException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Overrides:
  `close` in class `InputStream`
Throws:
  `IOException`