com.aliyun.oss.common.comm.io

## 类 BoundedInputStream

- java.lang.Object
- - java.io.InputStream
  - - com.aliyun.oss.common.comm.io.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.1.1

- - ### 构造器概要

    构造器
    构造器和说明
    `BoundedInputStream(InputStream in)` Creates a new `BoundedInputStream` that wraps the given input stream and is unlimited.
    `BoundedInputStream(InputStream in, long size)` Creates a new `BoundedInputStream` that wraps the given input stream and limits it to a certain size.

  - ### 方法概要

    方法
    限定符和类型 | 方法和说明
    --- | ---
    `int` | `available()`
    `protected void` | `backoff(long backoff)` Go back current position
    `void` | `close()` Invokes the delegate's `close()` method if `isPropagateClose()` is `true`.
    `InputStream` | `getWrappedInputStream()` Get original input stream
    `boolean` | `isPropagateClose()` Indicates whether the `close()` method should propagate to the underling `InputStream`.
    `void` | `mark(int readlimit)` Invokes the delegate's `mark(int)` method.
    `boolean` | `markSupported()` Invokes the delegate's `markSupported()` method.
    `int` | `read()` Invokes the delegate's `read()` method if the current position is less than the limit.
    `int` | `read(byte[] b)` Invokes the delegate's `read(byte[])` method.
    `int` | `read(byte[] b, int off, int len)` Invokes the delegate's `read(byte[], int, int)` method.
    `void` | `reset()` Invokes the delegate's `reset()` method.
    `void` | `setPropagateClose(boolean propagateClose)` Set whether the `close()` method should propagate to the underling `InputStream`.
    `long` | `skip(long n)` Invokes the delegate's `skip(long)` method.
    `String` | `toString()` Invokes the delegate's `toString()` method.

    - ### 从类继承的方法 java.lang.Object

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

- - ### 构造器详细资料

    - #### 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

          public BoundedInputStream(InputStream in)

      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` 在接口中 `Closeable`
      指定者:
        `close` 在接口中 `AutoCloseable`
      覆盖:
        `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.

    - #### getWrappedInputStream

          public InputStream getWrappedInputStream()

      Get original input stream
      返回:
        original input stream

    - #### backoff

          protected void backoff(long backoff)

      Go back current position
      参数:
        `backoff` -

Copyright © 2020. All Rights Reserved.