org.springframework.core.io.buffer

## 类 DataBufferUtils

- java.lang.Object
- - org.springframework.core.io.buffer.DataBufferUtils

-     public abstract class DataBufferUtils
      extends Object

  Utility class for working with `DataBuffer`s.
  从以下版本开始:
    5.0
  作者:
    Arjen Poutsma, Brian Clozel

- - ### 构造器概要

    构造器
    构造器和说明
    `DataBufferUtils()`

  - ### 方法概要

    所有方法 静态方法 具体方法 已过时的方法
    限定符和类型 | 方法和说明
    --- | ---
    `static reactor.core.publisher.Mono<DataBuffer>` | `join(org.reactivestreams.Publisher<DataBuffer> dataBuffers)` Return a new `DataBuffer` composed of the `dataBuffers` elements joined together.
    `static reactor.core.publisher.Flux<DataBuffer>` | `read(AsynchronousFileChannel channel, DataBufferFactory dataBufferFactory, int bufferSize)` 已过时。 as of Spring 5.0.3, in favor of `readAsynchronousFileChannel(Callable, DataBufferFactory, int)`, to be removed in Spring 5.1
    `static reactor.core.publisher.Flux<DataBuffer>` | `read(AsynchronousFileChannel channel, long position, DataBufferFactory dataBufferFactory, int bufferSize)` 已过时。 as of Spring 5.0.3, in favor of `readAsynchronousFileChannel(Callable, long, DataBufferFactory, int)`, to be removed in Spring 5.1
    `static reactor.core.publisher.Flux<DataBuffer>` | `read(InputStream inputStream, DataBufferFactory dataBufferFactory, int bufferSize)` 已过时。 as of Spring 5.0.3, in favor of `readInputStream(Callable, DataBufferFactory, int)`, to be removed in Spring 5.1
    `static reactor.core.publisher.Flux<DataBuffer>` | `read(ReadableByteChannel channel, DataBufferFactory dataBufferFactory, int bufferSize)` 已过时。 as of Spring 5.0.3, in favor of `readByteChannel(Callable, DataBufferFactory, int)`, to be removed in Spring 5.1
    `static reactor.core.publisher.Flux<DataBuffer>` | `read(Resource resource, DataBufferFactory dataBufferFactory, int bufferSize)` Read the given `Resource` into a `Flux` of `DataBuffer`s.
    `static reactor.core.publisher.Flux<DataBuffer>` | `read(Resource resource, long position, DataBufferFactory dataBufferFactory, int bufferSize)` Read the given `Resource` into a `Flux` of `DataBuffer`s starting at the given position.
    `static reactor.core.publisher.Flux<DataBuffer>` | `readAsynchronousFileChannel(Callable<AsynchronousFileChannel> channelSupplier, DataBufferFactory dataBufferFactory, int bufferSize)` Obtain a `AsynchronousFileChannel` from the given supplier, and read it into a `Flux` of `DataBuffer`s.
    `static reactor.core.publisher.Flux<DataBuffer>` | `readAsynchronousFileChannel(Callable<AsynchronousFileChannel> channelSupplier, long position, DataBufferFactory dataBufferFactory, int bufferSize)` Obtain a `AsynchronousFileChannel` from the given supplier, and read it into a `Flux` of `DataBuffer`s, starting at the given position.
    `static reactor.core.publisher.Flux<DataBuffer>` | `readByteChannel(Callable<ReadableByteChannel> channelSupplier, DataBufferFactory dataBufferFactory, int bufferSize)` Obtain a `ReadableByteChannel` from the given supplier, and read it into a `Flux` of `DataBuffer`s.
    `static reactor.core.publisher.Flux<DataBuffer>` | `readInputStream(Callable<InputStream> inputStreamSupplier, DataBufferFactory dataBufferFactory, int bufferSize)` Obtain a `InputStream` from the given supplier, and read it into a `Flux` of `DataBuffer`s.
    `static boolean` | `release(DataBuffer dataBuffer)` Release the given data buffer, if it is a `PooledDataBuffer`.
    `static Consumer<DataBuffer>` | `releaseConsumer()` Return a consumer that calls `release(DataBuffer)` on all passed data buffers.
    `static <T extends DataBuffer> T` | `retain(T dataBuffer)` Retain the given data buffer, it it is a `PooledDataBuffer`.
    `static reactor.core.publisher.Flux<DataBuffer>` | `skipUntilByteCount(org.reactivestreams.Publisher<DataBuffer> publisher, long maxByteCount)` Skip buffers from the given `Publisher` until the total byte count reaches the given maximum byte count, or until the publisher is complete.
    `static reactor.core.publisher.Flux<DataBuffer>` | `takeUntilByteCount(org.reactivestreams.Publisher<DataBuffer> publisher, long maxByteCount)` Relay buffers from the given `Publisher` until the total byte count reaches the given maximum byte count, or until the publisher is complete.
    `static reactor.core.publisher.Flux<DataBuffer>` | `write(org.reactivestreams.Publisher<DataBuffer> source, AsynchronousFileChannel channel)` Write the given stream of `DataBuffer`s to the given `AsynchronousFileChannel`.
    `static reactor.core.publisher.Flux<DataBuffer>` | `write(org.reactivestreams.Publisher<DataBuffer> source, AsynchronousFileChannel channel, long position)` Write the given stream of `DataBuffers` to the given `AsynchronousFileChannel`.
    `static reactor.core.publisher.Flux<DataBuffer>` | `write(org.reactivestreams.Publisher<DataBuffer> source, OutputStream outputStream)` Write the given stream of `DataBuffer`s to the given `OutputStream`.
    `static reactor.core.publisher.Flux<DataBuffer>` | `write(org.reactivestreams.Publisher<DataBuffer> source, WritableByteChannel channel)` Write the given stream of `DataBuffer`s to the given `WritableByteChannel`.

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

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

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

    - #### DataBufferUtils

          public DataBufferUtils()

  - ### 方法详细资料

    - #### read

          @Deprecated
          public static reactor.core.publisher.Flux<DataBuffer> read(InputStream inputStream,
                                                                                  DataBufferFactory dataBufferFactory,
                                                                                  int bufferSize)

      已过时。 as of Spring 5.0.3, in favor of `readInputStream(Callable, DataBufferFactory, int)`, to be removed in Spring 5.1
      Read the given `InputStream` into a read-once `Flux` of `DataBuffer`s. Closes the input stream when the flux is terminated.

      The resulting `Flux` can only be subscribed to once. See `readInputStream(Callable, DataBufferFactory, int)` for a variant that supports multiple subscriptions.

      参数:
        `inputStream` - the input stream to read from
        `dataBufferFactory` - the factory to create data buffers with
        `bufferSize` - the maximum size of the data buffers
      返回:
        a flux of data buffers read from the given channel

    - #### readInputStream

          public static reactor.core.publisher.Flux<DataBuffer> readInputStream(Callable<InputStream> inputStreamSupplier,
                                                                                DataBufferFactory dataBufferFactory,
                                                                                int bufferSize)

      Obtain a `InputStream` from the given supplier, and read it into a `Flux` of `DataBuffer`s. Closes the input stream when the flux is terminated.
      参数:
        `inputStreamSupplier` - the supplier for the input stream to read from
        `dataBufferFactory` - the factory to create data buffers with
        `bufferSize` - the maximum size of the data buffers
      返回:
        a flux of data buffers read from the given channel

    - #### read

          @Deprecated
          public static reactor.core.publisher.Flux<DataBuffer> read(ReadableByteChannel channel,
                                                                                  DataBufferFactory dataBufferFactory,
                                                                                  int bufferSize)

      已过时。 as of Spring 5.0.3, in favor of `readByteChannel(Callable, DataBufferFactory, int)`, to be removed in Spring 5.1
      Read the given `ReadableByteChannel` into a read-once `Flux` of `DataBuffer`s. Closes the channel when the flux is terminated.

      The resulting `Flux` can only be subscribed to once. See `readByteChannel(Callable, DataBufferFactory, int)` for a variant that supports multiple subscriptions.

      参数:
        `channel` - the channel to read from
        `dataBufferFactory` - the factory to create data buffers with
        `bufferSize` - the maximum size of the data buffers
      返回:
        a flux of data buffers read from the given channel

    - #### readByteChannel

          public static reactor.core.publisher.Flux<DataBuffer> readByteChannel(Callable<ReadableByteChannel> channelSupplier,
                                                                                DataBufferFactory dataBufferFactory,
                                                                                int bufferSize)

      Obtain a `ReadableByteChannel` from the given supplier, and read it into a `Flux` of `DataBuffer`s. Closes the channel when the flux is terminated.
      参数:
        `channelSupplier` - the supplier for the channel to read from
        `dataBufferFactory` - the factory to create data buffers with
        `bufferSize` - the maximum size of the data buffers
      返回:
        a flux of data buffers read from the given channel

    - #### read

          @Deprecated
          public static reactor.core.publisher.Flux<DataBuffer> read(AsynchronousFileChannel channel,
                                                                                  DataBufferFactory dataBufferFactory,
                                                                                  int bufferSize)

      已过时。 as of Spring 5.0.3, in favor of `readAsynchronousFileChannel(Callable, DataBufferFactory, int)`, to be removed in Spring 5.1
      Read the given `AsynchronousFileChannel` into a read-once `Flux` of `DataBuffer`s. Closes the channel when the flux is terminated.

      The resulting `Flux` can only be subscribed to once. See `readAsynchronousFileChannel(Callable, DataBufferFactory, int)` for a variant that supports multiple subscriptions.

      参数:
        `channel` - the channel to read from
        `dataBufferFactory` - the factory to create data buffers with
        `bufferSize` - the maximum size of the data buffers
      返回:
        a flux of data buffers read from the given channel

    - #### read

          @Deprecated
          public static reactor.core.publisher.Flux<DataBuffer> read(AsynchronousFileChannel channel,
                                                                                  long position,
                                                                                  DataBufferFactory dataBufferFactory,
                                                                                  int bufferSize)

      已过时。 as of Spring 5.0.3, in favor of `readAsynchronousFileChannel(Callable, long, DataBufferFactory, int)`, to be removed in Spring 5.1
      Read the given `AsynchronousFileChannel` into a read-once `Flux` of `DataBuffer`s, starting at the given position. Closes the channel when the flux is terminated.

      The resulting `Flux` can only be subscribed to once. See `readAsynchronousFileChannel(Callable, long, DataBufferFactory, int)` for a variant that supports multiple subscriptions.

      参数:
        `channel` - the channel to read from
        `position` - the position to start reading from
        `dataBufferFactory` - the factory to create data buffers with
        `bufferSize` - the maximum size of the data buffers
      返回:
        a flux of data buffers read from the given channel

    - #### readAsynchronousFileChannel

          public static reactor.core.publisher.Flux<DataBuffer> readAsynchronousFileChannel(Callable<AsynchronousFileChannel> channelSupplier,
                                                                                            DataBufferFactory dataBufferFactory,
                                                                                            int bufferSize)

      Obtain a `AsynchronousFileChannel` from the given supplier, and read it into a `Flux` of `DataBuffer`s. Closes the channel when the flux is terminated.
      参数:
        `channelSupplier` - the supplier for the channel to read from
        `dataBufferFactory` - the factory to create data buffers with
        `bufferSize` - the maximum size of the data buffers
      返回:
        a flux of data buffers read from the given channel

    - #### readAsynchronousFileChannel

          public static reactor.core.publisher.Flux<DataBuffer> readAsynchronousFileChannel(Callable<AsynchronousFileChannel> channelSupplier,
                                                                                            long position,
                                                                                            DataBufferFactory dataBufferFactory,
                                                                                            int bufferSize)

      Obtain a `AsynchronousFileChannel` from the given supplier, and read it into a `Flux` of `DataBuffer`s, starting at the given position. Closes the channel when the flux is terminated.
      参数:
        `channelSupplier` - the supplier for the channel to read from
        `position` - the position to start reading from
        `dataBufferFactory` - the factory to create data buffers with
        `bufferSize` - the maximum size of the data buffers
      返回:
        a flux of data buffers read from the given channel

    - #### read

          public static reactor.core.publisher.Flux<DataBuffer> read(Resource resource,
                                                                     DataBufferFactory dataBufferFactory,
                                                                     int bufferSize)

      Read the given `Resource` into a `Flux` of `DataBuffer`s.

      If the resource is a file, it is read into an `AsynchronousFileChannel` and turned to `Flux` via `readAsynchronousFileChannel(Callable, DataBufferFactory, int)` or else fall back to `readByteChannel(Callable, DataBufferFactory, int)`. Closes the channel when the flux is terminated.

      参数:
        `resource` - the resource to read from
        `dataBufferFactory` - the factory to create data buffers with
        `bufferSize` - the maximum size of the data buffers
      返回:
        a flux of data buffers read from the given channel

    - #### read

          public static reactor.core.publisher.Flux<DataBuffer> read(Resource resource,
                                                                     long position,
                                                                     DataBufferFactory dataBufferFactory,
                                                                     int bufferSize)

      Read the given `Resource` into a `Flux` of `DataBuffer`s starting at the given position.

      If the resource is a file, it is read into an `AsynchronousFileChannel` and turned to `Flux` via `readAsynchronousFileChannel(Callable, DataBufferFactory, int)` or else fall back on `readByteChannel(Callable, DataBufferFactory, int)`. Closes the channel when the flux is terminated.

      参数:
        `resource` - the resource to read from
        `position` - the position to start reading from
        `dataBufferFactory` - the factory to create data buffers with
        `bufferSize` - the maximum size of the data buffers
      返回:
        a flux of data buffers read from the given channel

    - #### write

          public static reactor.core.publisher.Flux<DataBuffer> write(org.reactivestreams.Publisher<DataBuffer> source,
                                                                      OutputStream outputStream)

      Write the given stream of `DataBuffer`s to the given `OutputStream`. Does not close the output stream when the flux is terminated, and does not release the data buffers in the source. If releasing is required, then subscribe to the returned `Flux` with a `releaseConsumer()`.

      Note that the writing process does not start until the returned `Flux` is subscribed to.

      参数:
        `source` - the stream of data buffers to be written
        `outputStream` - the output stream to write to
      返回:
        a flux containing the same buffers as in `source`, that starts the writing process when subscribed to, and that publishes any writing errors and the completion signal

    - #### write

          public static reactor.core.publisher.Flux<DataBuffer> write(org.reactivestreams.Publisher<DataBuffer> source,
                                                                      WritableByteChannel channel)

      Write the given stream of `DataBuffer`s to the given `WritableByteChannel`. Does not close the channel when the flux is terminated, and does not release the data buffers in the source. If releasing is required, then subscribe to the returned `Flux` with a `releaseConsumer()`.

      Note that the writing process does not start until the returned `Flux` is subscribed to.

      参数:
        `source` - the stream of data buffers to be written
        `channel` - the channel to write to
      返回:
        a flux containing the same buffers as in `source`, that starts the writing process when subscribed to, and that publishes any writing errors and the completion signal

    - #### write

          public static reactor.core.publisher.Flux<DataBuffer> write(org.reactivestreams.Publisher<DataBuffer> source,
                                                                      AsynchronousFileChannel channel)

      Write the given stream of `DataBuffer`s to the given `AsynchronousFileChannel`. Does not close the channel when the flux is terminated, and does not release the data buffers in the source. If releasing is required, then subscribe to the returned `Flux` with a `releaseConsumer()`.

      Note that the writing process does not start until the returned `Flux` is subscribed to.

      参数:
        `source` - the stream of data buffers to be written
        `channel` - the channel to write to
      返回:
        a flux containing the same buffers as in `source`, that starts the writing process when subscribed to, and that publishes any writing errors and the completion signal
      从以下版本开始:
        5.0.10

    - #### write

          public static reactor.core.publisher.Flux<DataBuffer> write(org.reactivestreams.Publisher<DataBuffer> source,
                                                                      AsynchronousFileChannel channel,
                                                                      long position)

      Write the given stream of `DataBuffers` to the given `AsynchronousFileChannel`. Does not close the channel when the flux is terminated, and does not release the data buffers in the source. If releasing is required, then subscribe to the returned `Flux` with a `releaseConsumer()`.

      Note that the writing process does not start until the returned `Flux` is subscribed to.

      参数:
        `source` - the stream of data buffers to be written
        `channel` - the channel to write to
        `position` - the file position at which the write is to begin; must be non-negative
      返回:
        a flux containing the same buffers as in `source`, that starts the writing process when subscribed to, and that publishes any writing errors and the completion signal

    - #### takeUntilByteCount

          public static reactor.core.publisher.Flux<DataBuffer> takeUntilByteCount(org.reactivestreams.Publisher<DataBuffer> publisher,
                                                                                   long maxByteCount)

      Relay buffers from the given `Publisher` until the total byte count reaches the given maximum byte count, or until the publisher is complete.
      参数:
        `publisher` - the publisher to filter
        `maxByteCount` - the maximum byte count
      返回:
        a flux whose maximum byte count is `maxByteCount`

    - #### skipUntilByteCount

          public static reactor.core.publisher.Flux<DataBuffer> skipUntilByteCount(org.reactivestreams.Publisher<DataBuffer> publisher,
                                                                                   long maxByteCount)

      Skip buffers from the given `Publisher` until the total byte count reaches the given maximum byte count, or until the publisher is complete.
      参数:
        `publisher` - the publisher to filter
        `maxByteCount` - the maximum byte count
      返回:
        a flux with the remaining part of the given publisher

    - #### retain

          public static <T extends DataBuffer> T retain(T dataBuffer)

      Retain the given data buffer, it it is a `PooledDataBuffer`.
      参数:
        `dataBuffer` - the data buffer to retain
      返回:
        the retained buffer

    - #### release

          public static boolean release(@Nullable
                                        DataBuffer dataBuffer)

      Release the given data buffer, if it is a `PooledDataBuffer`.
      参数:
        `dataBuffer` - the data buffer to release
      返回:
        `true` if the buffer was released; `false` otherwise.

    - #### releaseConsumer

          public static Consumer<DataBuffer> releaseConsumer()

      Return a consumer that calls `release(DataBuffer)` on all passed data buffers.

    - #### join

          public static reactor.core.publisher.Mono<DataBuffer> join(org.reactivestreams.Publisher<DataBuffer> dataBuffers)

      Return a new `DataBuffer` composed of the `dataBuffers` elements joined together. Depending on the `DataBuffer` implementation, the returned buffer may be a single buffer containing all data of the provided buffers, or it may be a true composite that contains references to the buffers.

      If `dataBuffers` contains an error signal, then all buffers that preceded the error will be released, and the error is stored in the returned `Mono`.

      参数:
        `dataBuffers` - the data buffers that are to be composed
      返回:
        a buffer that is composed from the `dataBuffers` argument
      从以下版本开始:
        5.0.3