### Question:
StreamReader implements Reader { public InputStream copyStream(OutputStream outStream) throws IOException { ByteBuffer buf = readStreamIntoBuffer(); outStream.write(buf.array(), 0, buf.limit()); return new ByteArrayInputStream(buf.array(), 0, buf.limit()); } StreamReader(InputStream stream);  StreamReader(InputStream stream, int contentLength);  StreamReader(InputStream stream, int estimatedContentLength, int maxContentLength); InputStream copyStream(OutputStream outStream); @Override ByteBuffer readStreamIntoBuffer(); @Override ByteBuffer readStreamIntoBuffer(ByteBuffer buffer); String readStreamIntoString(Charset charset); void readStreamToOutputStream(OutputStream outStream);  }### Answer:
@Test public void testCopyStream() throws IOException { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); InputStream result = new StreamReader(BAIS).copyStream(outStream); ByteBuffer resultBuffer = new StreamReader(result).readStreamIntoBuffer(); byte[] resultArr = new byte[resultBuffer.limit()]; resultBuffer.get(resultArr, 0, resultBuffer.limit()); Assert.assertTrue(Arrays.equals(resultArr, ARRAY)); Assert.assertTrue(Arrays.equals(outStream.toByteArray(), ARRAY)); }