? BoundedInputStream

java.lang.Object
java.io.InputStream
org.apache.commons.io.input.BoundedInputStream
????????:
Closeable, AutoCloseable

public class BoundedInputStream extends InputStream
This is a stream that will only supply bytes up to a certain length - if its position goes above that, it will stop.

This is useful to wrap ServletInputStreams. The ServletInputStream will block if you try to read content from it that isn't there, because it doesn't know whether the content hasn't arrived yet or whether the content has finished. So, one of these, initialized with the Content-length sent in the ServletInputStream's header, will stop it blocking, providing it's been sent with a correct content length.

???????:
2.0
  • ???????

    • BoundedInputStream

      public BoundedInputStream(InputStream in, long size)
      Creates a new BoundedInputStream that wraps the given input stream and limits it to a certain size.
      ??:
      in - The wrapped input stream
      size - The maximum number of bytes to return
    • BoundedInputStream

      Creates a new BoundedInputStream that wraps the given input stream and is unlimited.
      ??:
      in - The wrapped input stream
  • ??????

    • read

      public int read() throws IOException
      Invokes the delegate's read() method if the current position is less than the limit.
      ???:
      read ??? InputStream
      ??:
      the byte read or -1 if the end of stream or the limit has been reached.
      ??:
      IOException - if an I/O error occurs.
    • read

      public int read(byte[] b) throws IOException
      Invokes the delegate's read(byte[]) method.
      ??:
      read ??? InputStream
      ??:
      b - the buffer to read the bytes into
      ??:
      the number of bytes read or -1 if the end of stream or the limit has been reached.
      ??:
      IOException - if an I/O error occurs.
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Invokes the delegate's read(byte[], int, int) method.
      ??:
      read ??? InputStream
      ??:
      b - the buffer to read the bytes into
      off - The start offset
      len - The number of bytes to read
      ??:
      the number of bytes read or -1 if the end of stream or the limit has been reached.
      ??:
      IOException - if an I/O error occurs.
    • skip

      public long skip(long n) throws IOException
      Invokes the delegate's skip(long) method.
      ??:
      skip ??? InputStream
      ??:
      n - the number of bytes to skip
      ??:
      the actual number of bytes skipped
      ??:
      IOException - if an I/O error occurs.
    • available

      public int available() throws IOException
      ??:
      available ??? InputStream
      ??:
      IOException
    • toString

      public String toString()
      Invokes the delegate's toString() method.
      ??:
      toString ??? Object
      ??:
      the delegate's toString()
    • close

      public void close() throws IOException
      Invokes the delegate's close() method if isPropagateClose() is true.
      ???:
      close ???? AutoCloseable
      ???:
      close ???? Closeable
      ??:
      close ??? InputStream
      ??:
      IOException - if an I/O error occurs.
    • reset

      public void reset() throws IOException
      Invokes the delegate's reset() method.
      ??:
      reset ??? InputStream
      ??:
      IOException - if an I/O error occurs.
    • mark

      public void mark(int readlimit)
      Invokes the delegate's mark(int) method.
      ??:
      mark ??? InputStream
      ??:
      readlimit - read ahead limit
    • markSupported

      public boolean markSupported()
      Invokes the delegate's markSupported() method.
      ??:
      markSupported ??? InputStream
      ??:
      true if mark is supported, otherwise false
    • isPropagateClose

      public boolean isPropagateClose()
      Indicates whether the close() method should propagate to the underling InputStream.
      ??:
      true if calling close() propagates to the close() method of the underlying stream or false if it does not.
    • setPropagateClose

      public void setPropagateClose(boolean propagateClose)
      Set whether the close() method should propagate to the underling InputStream.
      ??:
      propagateClose - true if calling close() propagates to the close() method of the underlying stream or false if it does not.