RxIo icon indicating copy to clipboard operation
RxIo copied to clipboard

May we use BodyPublishers.ofFile as a read alternative to asynchronousfilechannel

Open fmcarvalho opened this issue 4 years ago • 0 comments

This looks to work fine:

Flow.Publisher<ByteBuffer> body = BodyPublishers.ofFile(metamorphosis);
Observable
    .fromPublisher(FlowAdapters.toPublisher(body))
    .take(10)
    .map(buf -> new String(buf.array()))
    .zipWith(Observable.interval(500, TimeUnit.MILLISECONDS), (item, interval) -> item)
    .subscribe(str -> System.out.println(str));
System.out.println("Subscribed");

fmcarvalho avatar May 15 '20 12:05 fmcarvalho