Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>An <code>OutputStream</code> is one where you write data to. If some module exposes an <code>OutputStream</code>, the expectation is that there is something reading at the other end.</p> <p>Something that exposes an <code>InputStream</code>, on the other hand, is indicating that you will need to listen to this stream, and there will be data that you can read. </p> <p>So it is possible to connect an <code>InputStream</code> to an <code>OutputStream</code></p> <p><code>InputStream----read---&gt; intermediateBytes[n] ----write----&gt; OutputStream</code></p> <p>As someone metioned, this is what the <code>copy()</code> method from <a href="http://commons.apache.org/proper/commons-io/javadocs/api-2.5/org/apache/commons/io/IOUtils.html" rel="noreferrer">IOUtils</a> lets you do. It does not make sense to go the other way... hopefully this makes some sense</p> <p><strong>UPDATE:</strong></p> <p>Of course the more I think of this, the more I can see how this actually would be a requirement. I know some of the comments mentioned <code>Piped</code> input/ouput streams, but there is another possibility.</p> <p>If the output stream that is exposed is a <code>ByteArrayOutputStream</code>, then you can always get the full contents by calling the <code>toByteArray()</code> method. Then you can create an input stream wrapper by using the <code>ByteArrayInputStream</code> sub-class. These two are pseudo-streams, they both basically just wrap an array of bytes. Using the streams this way, therefore, is technically possible, but to me it is still very strange...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload