Example usage for java.io PipedOutputStream write

List of usage examples for java.io PipedOutputStream write

Introduction

In this page you can find the example usage for java.io PipedOutputStream write.

Prototype

public void write(int b) throws IOException 

Source Link

Document

Writes the specified byte to the piped output stream.

Usage

From source file:ubicrypt.core.Utils.java

public static InputStream convert(final Observable<byte[]> source) {
    final PipedOutputStream pos = new PipedOutputStream();
    try {//from w  w w. j ava 2 s.  c o  m
        final PipedInputStream pis = new PipedInputStream(pos);
        source.subscribe(bytes -> {
            try {
                pos.write(bytes);
                pos.flush();
            } catch (final IOException e) {
                Throwables.propagate(e);
            }
        }, err -> {
            log.error(err.getMessage(), err);
            try {
                pis.close();
            } catch (final IOException e) {
            }
        });
        return pis;
    } catch (final IOException e) {
        Throwables.propagate(e);
    }
    return null;
}