类 DataBufferUtils

    • 方法详细资料

      • readInputStream

        public static reactor.core.publisher.Flux<DataBufferreadInputStream​(Callable<InputStream> inputStreamSupplier,
                                                                              DataBufferFactory bufferFactory,
                                                                              int bufferSize)
        Obtain a InputStream from the given supplier, and read it into a Flux of DataBuffers. Closes the input stream when the Flux is terminated.
        参数:
        inputStreamSupplier - the supplier for the input stream to read from
        bufferFactory - 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<DataBufferreadByteChannel​(Callable<ReadableByteChannel> channelSupplier,
                                                                              DataBufferFactory bufferFactory,
                                                                              int bufferSize)
        Obtain a ReadableByteChannel from the given supplier, and read it into a Flux of DataBuffers. Closes the channel when the Flux is terminated.
        参数:
        channelSupplier - the supplier for the channel to read from
        bufferFactory - 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<DataBufferreadAsynchronousFileChannel​(Callable<AsynchronousFileChannel> channelSupplier,
                                                                                          DataBufferFactory bufferFactory,
                                                                                          int bufferSize)
        Obtain a AsynchronousFileChannel from the given supplier, and read it into a Flux of DataBuffers. Closes the channel when the Flux is terminated.
        参数:
        channelSupplier - the supplier for the channel to read from
        bufferFactory - 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<DataBufferreadAsynchronousFileChannel​(Callable<AsynchronousFileChannel> channelSupplier,
                                                                                          long position,
                                                                                          DataBufferFactory bufferFactory,
                                                                                          int bufferSize)
        Obtain a AsynchronousFileChannel from the given supplier, and read it into a Flux of DataBuffers, 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
        bufferFactory - 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<DataBufferread​(Path path,
                                                                   DataBufferFactory bufferFactory,
                                                                   int bufferSize,
                                                                   OpenOption... options)
        Read bytes from the given file Path into a Flux of DataBuffers. The method ensures that the file is closed when the flux is terminated.
        参数:
        path - the path to read bytes from
        bufferFactory - 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
        从以下版本开始:
        5.2
      • read

        public static reactor.core.publisher.Flux<DataBufferread​(Resource resource,
                                                                   long position,
                                                                   DataBufferFactory bufferFactory,
                                                                   int bufferSize)
        Read the given Resource into a Flux of DataBuffers 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
        bufferFactory - 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<DataBufferwrite​(org.reactivestreams.Publisher<DataBuffer> source,
                                                                    OutputStream outputStream)
        Write the given stream of DataBuffers to the given OutputStream. Does not close the output stream when the flux is terminated, and does notrelease 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<DataBufferwrite​(org.reactivestreams.Publisher<DataBuffer> source,
                                                                    WritableByteChannel channel)
        Write the given stream of DataBuffers to the given WritableByteChannel. Does not close the channel when the flux is terminated, and does notrelease 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<DataBufferwrite​(org.reactivestreams.Publisher<DataBuffer> source,
                                                                    AsynchronousFileChannel channel)
        Write the given stream of DataBuffers to the given AsynchronousFileChannel. Does not close the channel when the flux is terminated, and does notrelease 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<DataBufferwrite​(org.reactivestreams.Publisher<? extends 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 notrelease 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 where writing 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
      • write

        public static reactor.core.publisher.Mono<Voidwrite​(org.reactivestreams.Publisher<DataBuffer> source,
                                                              Path destination,
                                                              OpenOption... options)
        Write the given stream of DataBuffers to the given file Path. The optional options parameter specifies how the file is created or opened (defaults to CREATE, TRUNCATE_EXISTING, and WRITE).
        参数:
        source - the stream of data buffers to be written
        destination - the path to the file
        options - the options specifying how the file is opened
        返回:
        a Mono that indicates completion or error
        从以下版本开始:
        5.2
      • takeUntilByteCount

        public static reactor.core.publisher.Flux<DataBuffertakeUntilByteCount​(org.reactivestreams.Publisher<? extends 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<DataBufferskipUntilByteCount​(org.reactivestreams.Publisher<? extends 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, if 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 and has been allocated.
        参数:
        dataBuffer - the data buffer to release
        返回:
        true if the buffer was released; false otherwise.
      • join

        public static reactor.core.publisher.Mono<DataBufferjoin​(org.reactivestreams.Publisher<? extends DataBuffer> dataBuffers)
        Return a new DataBuffer composed from joining together the given dataBuffers elements. Depending on the DataBuffer type, the returned buffer may be a single buffer containing all data of the provided buffers, or it may be a zero-copy, composite with references to the given buffers.

        If dataBuffers produces an error or if there is a cancel signal, then all accumulated buffers will be released.

        Note that the given data buffers do not have to be released. They will be released as part of the returned composite.

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

        public static reactor.core.publisher.Mono<DataBufferjoin​(org.reactivestreams.Publisher<? extends DataBuffer> buffers,
                                                                   int maxByteCount)
        Variant of join(Publisher) that behaves the same way up until the specified max number of bytes to buffer. Once the limit is exceeded, DataBufferLimitException is raised.
        参数:
        buffers - the data buffers that are to be composed
        maxByteCount - the max number of bytes to buffer, or -1 for unlimited
        返回:
        a buffer with the aggregated content, possibly an empty Mono if the max number of bytes to buffer is exceeded.
        抛出:
        DataBufferLimitException - if maxByteCount is exceeded
        从以下版本开始:
        5.1.11
      • matcher

        public static DataBufferUtils.Matcher matcher​(byte[] delimiter)
        Return a DataBufferUtils.Matcher for the given delimiter. The matcher can be used to find the delimiters in a stream of data buffers.
        参数:
        delimiter - the delimiter bytes to find
        返回:
        the matcher
        从以下版本开始:
        5.2
      • matcher

        public static DataBufferUtils.Matcher matcher​(byte[]... delimiters)
        Return a DataBufferUtils.Matcher for the given delimiters. The matcher can be used to find the delimiters in a stream of data buffers.
        参数:
        delimiters - the delimiters bytes to find
        返回:
        the matcher
        从以下版本开始:
        5.2