public abstract class DataBufferUtils extends Object
DataBuffers.| Modifier and Type | Class and Description | 
|---|---|
| static interface  | DataBufferUtils.MatcherDefines an object that matches a data buffer against a delimiter. | 
| Constructor and Description | 
|---|
| DataBufferUtils() | 
| Modifier and Type | Method and Description | 
|---|---|
| static reactor.core.publisher.Mono<DataBuffer> | join(org.reactivestreams.Publisher<? extends DataBuffer> dataBuffers)Return a new  DataBuffercomposed from joining together the givendataBufferselements. | 
| static reactor.core.publisher.Mono<DataBuffer> | join(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. | 
| static DataBufferUtils.Matcher | matcher(byte[]... delimiters)Return a  DataBufferUtils.Matcherfor the given delimiters. | 
| static DataBufferUtils.Matcher | matcher(byte[] delimiter)Return a  DataBufferUtils.Matcherfor the given delimiter. | 
| static reactor.core.publisher.Flux<DataBuffer> | read(Path path,
    DataBufferFactory bufferFactory,
    int bufferSize,
    OpenOption... options)Read bytes from the given file  Pathinto aFluxofDataBuffers. | 
| static reactor.core.publisher.Flux<DataBuffer> | read(Resource resource,
    DataBufferFactory bufferFactory,
    int bufferSize)Read the given  Resourceinto aFluxofDataBuffers. | 
| static reactor.core.publisher.Flux<DataBuffer> | read(Resource resource,
    long position,
    DataBufferFactory bufferFactory,
    int bufferSize)Read the given  Resourceinto aFluxofDataBuffers
 starting at the given position. | 
| static reactor.core.publisher.Flux<DataBuffer> | readAsynchronousFileChannel(Callable<AsynchronousFileChannel> channelSupplier,
                           DataBufferFactory bufferFactory,
                           int bufferSize)Obtain a  AsynchronousFileChannelfrom the given supplier, and read
 it into aFluxofDataBuffers. | 
| static reactor.core.publisher.Flux<DataBuffer> | readAsynchronousFileChannel(Callable<AsynchronousFileChannel> channelSupplier,
                           long position,
                           DataBufferFactory bufferFactory,
                           int bufferSize)Obtain a  AsynchronousFileChannelfrom the given supplier, and
 read it into aFluxofDataBuffers, starting at the given
 position. | 
| static reactor.core.publisher.Flux<DataBuffer> | readByteChannel(Callable<ReadableByteChannel> channelSupplier,
               DataBufferFactory bufferFactory,
               int bufferSize) | 
| static reactor.core.publisher.Flux<DataBuffer> | readInputStream(Callable<InputStream> inputStreamSupplier,
               DataBufferFactory bufferFactory,
               int bufferSize) | 
| static boolean | release(DataBuffer dataBuffer)Release the given data buffer, if it is a  PooledDataBufferand
 has been allocated. | 
| static Consumer<DataBuffer> | releaseConsumer()Return a consumer that calls  release(DataBuffer)on all
 passed data buffers. | 
| static <T extends DataBuffer> | retain(T dataBuffer)Retain the given data buffer, if it is a  PooledDataBuffer. | 
| static reactor.core.publisher.Flux<DataBuffer> | skipUntilByteCount(org.reactivestreams.Publisher<? extends DataBuffer> publisher,
                  long maxByteCount)Skip buffers from the given  Publisheruntil 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<? extends DataBuffer> publisher,
                  long maxByteCount)Relay buffers from the given  Publisheruntil 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<? extends DataBuffer> source,
     AsynchronousFileChannel channel,
     long position)Write the given stream of  DataBuffersto the givenAsynchronousFileChannel. | 
| static reactor.core.publisher.Flux<DataBuffer> | write(org.reactivestreams.Publisher<DataBuffer> source,
     AsynchronousFileChannel channel)Write the given stream of  DataBuffersto the givenAsynchronousFileChannel. | 
| static reactor.core.publisher.Flux<DataBuffer> | write(org.reactivestreams.Publisher<DataBuffer> source,
     OutputStream outputStream)Write the given stream of  DataBuffersto the givenOutputStream. | 
| static reactor.core.publisher.Mono<Void> | write(org.reactivestreams.Publisher<DataBuffer> source,
     Path destination,
     OpenOption... options)Write the given stream of  DataBuffersto the given
 filePath. | 
| static reactor.core.publisher.Flux<DataBuffer> | write(org.reactivestreams.Publisher<DataBuffer> source,
     WritableByteChannel channel)Write the given stream of  DataBuffersto the givenWritableByteChannel. | 
public static reactor.core.publisher.Flux<DataBuffer> readInputStream(Callable<InputStream> inputStreamSupplier, DataBufferFactory bufferFactory, int bufferSize)
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 frombufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data bufferspublic static reactor.core.publisher.Flux<DataBuffer> readByteChannel(Callable<ReadableByteChannel> channelSupplier, DataBufferFactory bufferFactory, int bufferSize)
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 frombufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data bufferspublic static reactor.core.publisher.Flux<DataBuffer> readAsynchronousFileChannel(Callable<AsynchronousFileChannel> channelSupplier, DataBufferFactory bufferFactory, int bufferSize)
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 frombufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data bufferspublic static reactor.core.publisher.Flux<DataBuffer> readAsynchronousFileChannel(Callable<AsynchronousFileChannel> channelSupplier, long position, DataBufferFactory bufferFactory, int bufferSize)
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 fromposition - the position to start reading frombufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data bufferspublic static reactor.core.publisher.Flux<DataBuffer> read(Path path, DataBufferFactory bufferFactory, int bufferSize, OpenOption... options)
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 frombufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data bufferspublic static reactor.core.publisher.Flux<DataBuffer> read(Resource resource, DataBufferFactory bufferFactory, int bufferSize)
Resource into a Flux of DataBuffers.
 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 frombufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data bufferspublic static reactor.core.publisher.Flux<DataBuffer> read(Resource resource, long position, DataBufferFactory bufferFactory, int bufferSize)
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 fromposition - the position to start reading frombufferFactory - the factory to create data buffers withbufferSize - the maximum size of the data bufferspublic static reactor.core.publisher.Flux<DataBuffer> write(org.reactivestreams.Publisher<DataBuffer> source, OutputStream outputStream)
DataBuffers 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 writtenoutputStream - the output stream to write tosource, that
 starts the writing process when subscribed to, and that publishes any
 writing errors and the completion signalpublic static reactor.core.publisher.Flux<DataBuffer> write(org.reactivestreams.Publisher<DataBuffer> source, WritableByteChannel channel)
DataBuffers 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 writtenchannel - the channel to write tosource, that
 starts the writing process when subscribed to, and that publishes any
 writing errors and the completion signalpublic static reactor.core.publisher.Flux<DataBuffer> write(org.reactivestreams.Publisher<DataBuffer> source, AsynchronousFileChannel channel)
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 writtenchannel - the channel to write tosource, that
 starts the writing process when subscribed to, and that publishes any
 writing errors and the completion signalpublic static reactor.core.publisher.Flux<DataBuffer> write(org.reactivestreams.Publisher<? extends DataBuffer> source, AsynchronousFileChannel channel, long position)
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 writtenchannel - the channel to write toposition - file position write write is to begin; must be non-negativesource, that
 starts the writing process when subscribed to, and that publishes any
 writing errors and the completion signalpublic static reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<DataBuffer> source, Path destination, OpenOption... options)
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 writtendestination - the path to the fileoptions - options specifying how the file is openedMono that indicates completion or errorpublic static reactor.core.publisher.Flux<DataBuffer> takeUntilByteCount(org.reactivestreams.Publisher<? extends DataBuffer> publisher, long maxByteCount)
Publisher until the total
 byte count reaches
 the given maximum byte count, or until the publisher is complete.publisher - the publisher to filtermaxByteCount - the maximum byte countmaxByteCountpublic static reactor.core.publisher.Flux<DataBuffer> skipUntilByteCount(org.reactivestreams.Publisher<? extends DataBuffer> publisher, long maxByteCount)
Publisher until the total
 byte count reaches
 the given maximum byte count, or until the publisher is complete.publisher - the publisher to filtermaxByteCount - the maximum byte countpublic static <T extends DataBuffer> T retain(T dataBuffer)
PooledDataBuffer.dataBuffer - the data buffer to retainpublic static boolean release(@Nullable DataBuffer dataBuffer)
PooledDataBuffer and
 has been allocated.dataBuffer - the data buffer to releasetrue if the buffer was released; false otherwise.public static Consumer<DataBuffer> releaseConsumer()
release(DataBuffer) on all
 passed data buffers.public static reactor.core.publisher.Mono<DataBuffer> join(org.reactivestreams.Publisher<? extends DataBuffer> dataBuffers)
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 composeddataBuffers argumentpublic static reactor.core.publisher.Mono<DataBuffer> join(org.reactivestreams.Publisher<? extends DataBuffer> buffers, int maxByteCount)
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 composedmaxByteCount - the max number of bytes to buffer, or -1 for unlimitedDataBufferLimitException - if maxByteCount is exceededpublic static DataBufferUtils.Matcher matcher(byte[] delimiter)
DataBufferUtils.Matcher for the given delimiter.
 The matcher can be used to find the delimiters in data buffers.delimiter - the delimiter bytes to findpublic static DataBufferUtils.Matcher matcher(byte[]... delimiters)
DataBufferUtils.Matcher for the given delimiters.
 The matcher can be used to find the delimiters in data buffers.delimiters - the delimiters bytes to find