title: Best practice to provide an OutputStream and InputStream that are connected
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1574837/connecting-an-input-stream-to-an-outputstream">Connecting an input stream to an outputstream</a>  </p>
  </blockquote>
  
  
  
  <p>If I have a method that expects an OutputStream (from a third-party library), and another method that expects an InputStream (again from a third-party library). What's the best practice for bridging the two together? Basically I need some sort of object that will provide both an InputStream and OutputStream that are connected.</p>
  
  <p>I thought of an approach using SynchronousQueue, but having to convert and un-convert each primitive byte into an Object Byte doesn't sound like a very good idea.</p>
  
  <p>I would prefer not to use temp files, and buffering the entire InputStream is out of the question, as the data can be quite large.</p>
  
  <p>Edit: Also, I would like to keep this single-threaded if possible.</p>
  
  <p>What's the best practice here?</p>
  
  <p>Edit: I need to clarify: I do not have an InputStream OR an OutputStream, just two methods. One expecting an OutputStream to write data to, and another expecting an InputStream to read data from. </p>