Package org.jsoup.internal

# Class ConstrainableInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.BufferedInputStream
org.jsoup.internal.ConstrainableInputStream

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

public final class ConstrainableInputStream extends BufferedInputStream
A jsoup internal class (so don't use it as there is no contract API) that enables constraints on an Input Stream, namely a maximum read size, and the ability to Thread.interrupt() the read.

## Field Summary

### Fields inherited from class java.io.BufferedInputStream

`buf, count, marklimit, markpos, pos`

### Fields inherited from class java.io.FilterInputStream

`in`

## Method Summary

Modifier and Type
Method
Description
`int`
`read(byte[] b, int off, int len)`
`ByteBuffer`
`readToByteBuffer(int max)`
Reads this inputstream to a ByteBuffer.
`void`
`reset()`
`ConstrainableInputStream`
`timeout(long startTimeNanos, long timeoutMillis)`
`static ConstrainableInputStream`
`wrap(InputStream in, int bufferSize, int maxSize)`
If this InputStream is not already a ConstrainableInputStream, let it be one.

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

`available, close, mark, markSupported, read, skip, transferTo`

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

`read`

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

`nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes`

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

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

## Method Details

### wrap

public static ConstrainableInputStream wrap(InputStream in, int bufferSize, int maxSize)
If this InputStream is not already a ConstrainableInputStream, let it be one.

Parameters:
  `in` - the input stream to (maybe) wrap
  `bufferSize` - the buffer size to use when reading
  `maxSize` - the maximum size to allow to be read. 0 == infinite.
Returns:
  a constrainable input stream

### read

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

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

### readToByteBuffer

public ByteBuffer readToByteBuffer(int max) throws IOException
Reads this inputstream to a ByteBuffer. The supplied max may be less than the inputstream's max, to support reading just the first bytes.

Throws:
  `IOException`

### reset

public void reset() throws IOException

Overrides:
  `reset` in class `BufferedInputStream`
Throws:
  `IOException`

### timeout

public ConstrainableInputStream timeout(long startTimeNanos, long timeoutMillis)