Possible Duplicate:
Connecting an input stream to an outputstream
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.
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.
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.
Edit: Also, I would like to keep this single-threaded if possible.
What's the best practice here?
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.