Top Description Methods
io.vertx.core.streams

public Interface ReadStream<T>

extends StreamBase
Known Direct Subinterfaces
io.vertx.core.TimeoutStream, io.vertx.core.datagram.DatagramSocket, io.vertx.core.eventbus.MessageConsumer, io.vertx.core.file.AsyncFile, io.vertx.core.http.HttpServerFileUpload, io.vertx.core.http.HttpClientResponse, io.vertx.core.http.HttpServerRequest, io.vertx.core.http.WebSocketBase, io.vertx.core.net.NetSocket, io.vertx.core.parsetools.JsonParser, io.vertx.core.parsetools.RecordParser
Known Direct Implementers
io.vertx.core.eventbus.impl.BodyReadStream, io.vertx.core.http.impl.HttpServerImpl.HttpStreamHandler, io.vertx.core.http.impl.NettyFileUpload, io.vertx.core.net.impl.NetServerImpl.NetSocketStream
Annotations
@VertxGen
concrete:false
Imports
io.vertx.codegen.annotations.Fluent, .GenIgnore, .Nullable, .VertxGen, io.vertx.core.AsyncResult, .Future, .Handler, .Promise, io.vertx.core.impl.future.PromiseInternal, io.vertx.core.streams.impl.PipeImpl, java.util.function.BiConsumer

Represents a stream of items that can be read from.

Any class that implements this interface can be used by a Pipe to pipe data from it to a WriteStream.

Streaming mode

The stream is either in flowing or fetch mode. The mode can be changed with the pause(), resume() and fetch methods:
Author
Tim Fox

Method Summary

Modifier and TypeMethod and Description
public default <R, A> Future<R>

Returns:

a future notified with result produced by the collector applied to this stream
collect
(Collector<T, A, R> collector)

Apply a collector to this stream, the obtained result is returned as a future.

public ReadStream<T>

Returns:

a reference to this, so the API can be used fluently
endHandler
(@Nullable Handler<Void> endHandler)

Set an end handler.

public ReadStream<T>

Returns:

a reference to this, so the API can be used fluently
exceptionHandler
(@Nullable Handler<Throwable>
the exception handler
handler
)

Set an exception handler on the read stream.

public ReadStream<T>

Returns:

a reference to this, so the API can be used fluently
fetch
(long amount)

Fetch the specified amount of elements.

public ReadStream<T>

Returns:

a reference to this, so the API can be used fluently
handler
(@Nullable Handler<T> handler)

Set a data handler.

public ReadStream<T>

Returns:

a reference to this, so the API can be used fluently
pause
()

Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

public default Pipe<T>

Returns:

a pipe
pipe
()

Pause this stream and return a Pipe to transfer the elements of this stream to a destination WriteStream.

public default Future<Void>
pipeTo(WriteStream<T> dst)

Same as pipeTo(WriteStream, Handler) but returns a Future of the asynchronous result

public default void
pipeTo(WriteStream<T>
the destination write stream
dst
,
Handler<AsyncResult<Void>> handler)

Pipe this ReadStream to the WriteStream.

public ReadStream<T>

Returns:

a reference to this, so the API can be used fluently
resume
()

Resume reading, and sets the buffer in flowing mode.

Inherited from io.vertx.core.streams.StreamBase:
exceptionHandler

Method Detail

collectback to summary
public default <R, A> Future<R> collect(Collector<T, A, R> collector)

Apply a collector to this stream, the obtained result is returned as a future.

Handlers of this stream are affected by this operation.

Returns:Future<R>

a future notified with result produced by the collector applied to this stream

Annotations
@GenIgnore
endHandlerback to summary
public ReadStream<T> endHandler(@Nullable Handler<Void> endHandler)

Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.

Returns:ReadStream<T>

a reference to this, so the API can be used fluently

Annotations
@Fluent
exceptionHandlerback to summary
public ReadStream<T> exceptionHandler(@Nullable Handler<Throwable> handler)

Set an exception handler on the read stream.

Parameters
handler:@Nullable Handler<Throwable>

the exception handler

Returns:ReadStream<T>

a reference to this, so the API can be used fluently

fetchback to summary
public ReadStream<T> fetch(long amount)

Fetch the specified amount of elements. If the ReadStream has been paused, reading will recommence with the specified amount of items, otherwise the specified amount will be added to the current stream demand.

Returns:ReadStream<T>

a reference to this, so the API can be used fluently

Annotations
@Fluent
handlerback to summary
public ReadStream<T> handler(@Nullable Handler<T> handler)

Set a data handler. As data is read, the handler will be called with the data.

Returns:ReadStream<T>

a reference to this, so the API can be used fluently

Annotations
@Fluent
pauseback to summary
public ReadStream<T> pause()

Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

While it's paused, no data will be sent to the data handler.

Returns:ReadStream<T>

a reference to this, so the API can be used fluently

Annotations
@Fluent
pipeback to summary
public default Pipe<T> pipe()

Pause this stream and return a Pipe to transfer the elements of this stream to a destination WriteStream.

The stream will be resumed when the pipe will be wired to a WriteStream.

Returns:Pipe<T>

a pipe

pipeToback to summary
public default Future<Void> pipeTo(WriteStream<T> dst)

Same as pipeTo(WriteStream, Handler) but returns a Future of the asynchronous result

pipeToback to summary
public default void pipeTo(WriteStream<T> dst, Handler<AsyncResult<Void>> handler)

Pipe this ReadStream to the WriteStream.

Elements emitted by this stream will be written to the write stream until this stream ends or fails.

Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

Parameters
dst:WriteStream<T>

the destination write stream

resumeback to summary
public ReadStream<T> resume()

Resume reading, and sets the buffer in flowing mode.

If the ReadStream has been paused, reading will recommence on it.

Returns:ReadStream<T>

a reference to this, so the API can be used fluently

Annotations
@Fluent