Class ControllableInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.jsoup.internal.ControllableInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class ControllableInputStream extends FilterInputStream
A jsoup internal class (so don't use it as there is no contract API) that enables controls on a Buffered Input Stream, namely a maximum read size, and the ability to Thread.interrupt() the read.
  • Field Details

    • buff

      private final BufferedInputStream buff
    • capped

      private final boolean capped
    • maxSize

      private final int maxSize
    • startTime

      private long startTime
    • timeout

      private long timeout
    • remaining

      private int remaining
    • markPos

      private int markPos
    • interrupted

      private boolean interrupted
  • Constructor Details

    • ControllableInputStream

      private ControllableInputStream(BufferedInputStream in, int maxSize)
  • Method Details

    • wrap

      public static ControllableInputStream wrap(InputStream in, int bufferSize, int maxSize)
      If this InputStream is not already a ControllableInputStream, 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 controllable input stream
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Overrides:
      read in class FilterInputStream
      Throws:
      IOException
    • readToByteBuffer

      public static ByteBuffer readToByteBuffer(InputStream in, 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 FilterInputStream
      Throws:
      IOException
    • mark

      public void mark(int readlimit)
      Overrides:
      mark in class FilterInputStream
    • timeout

      public ControllableInputStream timeout(long startTimeNanos, long timeoutMillis)
    • expired

      private boolean expired()
    • inputStream

      public BufferedInputStream inputStream()