How to use EasyStream classes

This is a definition of the current problem you come here for:

  • A function (usually in an external library) produces some data, and wants to put them on an OutputStream
  • Another function wants to process the previous data, and expect to read them from an InputStream
   OutputStream out = ?; //what to put here?
   InputStream in = ?;

   ??? // 'convert' out to in

This is the snippet of code that solves the problem using EasyStream:

final OutputStreamToInputStream<Void> out = new OutputStreamToInputStream<Void>() {
    protected Void doRead(final InputStream istream) throws Exception {
           * Read the data from the InputStream "istream" passed as parameter. 
           return null;
try {   
} finally {
     // don't miss the close (or a thread would not terminate correctly).

For more options and use cases you can have a look to the reference guide.

Reference guide Next