Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can write a custom <code>InputStream</code> implementation that does this. Example:</p> <pre><code>import java.io.IOException; import java.io.InputStream; import java.util.Collections; import java.util.Deque; import java.util.LinkedList; public class CatInputStream extends InputStream { private final Deque&lt;InputStream&gt; streams; public CatInputStream(InputStream... streams) { this.streams = new LinkedList&lt;InputStream&gt;(); Collections.addAll(this.streams, streams); } private void nextStream() throws IOException { streams.removeFirst().close(); } @Override public int read() throws IOException { int result = -1; while (!streams.isEmpty() &amp;&amp; (result = streams.getFirst().read()) == -1) { nextStream(); } return result; } @Override public int read(byte b[], int off, int len) throws IOException { int result = -1; while (!streams.isEmpty() &amp;&amp; (result = streams.getFirst().read(b, off, len)) == -1) { nextStream(); } return result; } @Override public long skip(long n) throws IOException { long skipped = 0L; while (skipped &lt; n &amp;&amp; !streams.isEmpty()) { int thisSkip = streams.getFirst().skip(n - skipped); if (thisSkip &gt; 0) skipped += thisSkip; else nextStream(); } return skipped; } @Override public int available() throws IOException { return streams.isEmpty() ? 0 : streams.getFirst().available(); } @Override public void close() throws IOException { while (!streams.isEmpty()) nextStream(); } } </code></pre> <p>This code isn't tested, so your mileage may vary.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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