public interface IoMulti
Create reactive stream from standard IO resources.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final class
Fluent API builder for creating aMulti
from aReadableByteChannel
.static final class
Fluent API builder for creating aMulti
from anInputStream
.static final class
Fluent API builder for creating a subscriber consumingMulti<ByteBuffer>
toWritableByteChannel
.static final class
Fluent API builder forOutputStreamMulti
. -
Method Summary
Modifier and TypeMethodDescriptionbuilderInputStream
(InputStream inputStream) Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Please useoutputStreamMultiBuilder()
static Multi<ByteBuffer>
createInputStream
(InputStream inputStream) Deprecated, for removal: This API element is subject to removal in a future version.please usemultiFromStream(java.io.InputStream)
static OutputStreamMulti
Deprecated, for removal: This API element is subject to removal in a future version.Please useoutputStreamMulti()
static Multi<ByteBuffer>
multiFromByteChannel
(ReadableByteChannel byteChannel) Creates a multi that reads data from the provided byte channel.multiFromByteChannelBuilder
(ReadableByteChannel byteChannel) Creates a builder ofMulti
from providedReadableByteChannel
.static Multi<ByteBuffer>
multiFromStream
(InputStream inputStream) multiFromStreamBuilder
(InputStream inputStream) Creates a builder of theMulti
from suppliedInputStream
.static Function<? super Multi<ByteBuffer>,
? extends Single<Void>> multiToByteChannel
(WritableByteChannel writableChannel) Creates function consumingMulti<ByteBuffer>
to suppliedWritableByteChannel
.multiToByteChannelBuilder
(WritableByteChannel byteChannel) Creates function consumingMulti<ByteBuffer>
to suppliedWritableByteChannel
.static OutputStreamMulti
Create anOutputStream
that provides the data written as aMulti
.Creates a builder of theOutputStream
that provides data written as aMulti
.writeToFile
(Path filePath)
-
Method Details
-
createOutputStream
Deprecated, for removal: This API element is subject to removal in a future version.Please useoutputStreamMulti()
Create anOutputStream
that provides the data written as aMulti
.In case there is no demand,
OutputStream.write(byte[], int, int)
methods are blocked until downstream request for more data.- Returns:
- new
Multi
publisher extendingOutputStream
-
outputStreamMulti
Create anOutputStream
that provides the data written as aMulti
.In case there is no demand,
OutputStream.write(byte[], int, int)
methods are blocked until downstream request for more data.- Returns:
- new
OutputStream
implementingMulti
-
builderOutputStream
@Deprecated(since="2.0.0", forRemoval=true) static IoMulti.OutputStreamMultiBuilder builderOutputStream()Deprecated, for removal: This API element is subject to removal in a future version.Please useoutputStreamMultiBuilder()
Creates a builder of theOutputStream
that provides data written as aMulti
.- Returns:
- the builder
- See Also:
-
outputStreamMultiBuilder
Creates a builder of theOutputStream
that provides data written as aMulti
.- Returns:
- the builder
- See Also:
-
createInputStream
@Deprecated(since="2.0.0", forRemoval=true) static Multi<ByteBuffer> createInputStream(InputStream inputStream) Deprecated, for removal: This API element is subject to removal in a future version.please usemultiFromStream(java.io.InputStream)
Create aMulti
instance that publishesByteBuffer
s from the givenInputStream
.InputStream
is trusted not to block on read operations, in case it can't be assured use builder to specify executor for asynchronous waiting for blocking reads.IoMulti.builder(is).executor(executorService).build()
.- Parameters:
inputStream
- the Stream to publish- Returns:
- Multi
- Throws:
NullPointerException
- ifstream
isnull
-
multiFromStream
Create aMulti
instance that publishesByteBuffer
s from the givenInputStream
.InputStream
is trusted not to block on read operations, in case it can't be assured use builder to specify executor for asynchronous waiting for blocking reads.IoMulti.builder(is).executor(executorService).build()
.- Parameters:
inputStream
- the Stream to publish- Returns:
- Multi
-
builderInputStream
@Deprecated(since="2.0.0", forRemoval=true) static IoMulti.MultiFromInputStreamBuilder builderInputStream(InputStream inputStream) Deprecated, for removal: This API element is subject to removal in a future version.Please usemultiFromStreamBuilder(java.io.InputStream)
Creates a builder of theMulti
from suppliedInputStream
.- Parameters:
inputStream
- the Stream to publish- Returns:
- the builder
-
multiFromStreamBuilder
Creates a builder of theMulti
from suppliedInputStream
.- Parameters:
inputStream
- the Stream to publish- Returns:
- the builder
-
multiFromByteChannel
Creates a multi that reads data from the provided byte channel. The multi uses an executor service to process asynchronous reads. You can provide a custom executor service usingmultiFromByteChannelBuilder(java.nio.channels.ReadableByteChannel)
.- Parameters:
byteChannel
- readable byte channel with data- Returns:
- publisher of data from the provided channel
-
multiToByteChannel
static Function<? super Multi<ByteBuffer>,? extends Single<Void>> multiToByteChannel(WritableByteChannel writableChannel) Creates function consumingMulti<ByteBuffer>
to suppliedWritableByteChannel
.
Example usage:Multi.create(listOfByteBuffers) .map(s -> ByteBuffer.wrap(s.getBytes(StandardCharsets.UTF_8))) .to(IoMulti.multiToByteChannel(fileChannel)) .await();
- Parameters:
writableChannel
- for consuming ByteBuffers from upstream- Returns:
- mapper consuming
Multi<ByteBuffer>
and returning Single for observing asynchronous writing.
-
multiToByteChannelBuilder
Creates function consumingMulti<ByteBuffer>
to suppliedWritableByteChannel
.
Example usage:Multi.create(listOfByteBuffers) .map(s -> ByteBuffer.wrap(s.getBytes(StandardCharsets.UTF_8))) .to(IoMulti.multiToByteChannelBuilder(fileChannel) .executor(customExecutor) .build()) .await();
- Parameters:
byteChannel
- for consuming ByteBuffers from upstream- Returns:
- mapper consuming
Multi<ByteBuffer>
and returning Single for observing asynchronous writing.
-
writeToFile
Creates function consumingMulti<ByteBuffer>
toFileChannel
opened from suppliedPath
.
Example usage:Multi.create(listOfByteBuffers) .map(s -> ByteBuffer.wrap(s.getBytes(StandardCharsets.UTF_8))) .to(IoMulti.writeToFile(path) .executor(customExecutor) .build()) .await();
- Parameters:
filePath
- file for writing all ByteBuffers from upstream to- Returns:
- mapper consuming
Multi<ByteBuffer>
and returning Single for observing asynchronous writing.
-
multiFromByteChannelBuilder
static IoMulti.MultiFromByteChannelBuilder multiFromByteChannelBuilder(ReadableByteChannel byteChannel) Creates a builder ofMulti
from providedReadableByteChannel
.- Parameters:
byteChannel
- readable byte channel with data- Returns:
- fluent API builder to configure additional details
-
multiFromStreamBuilder(java.io.InputStream)