ByteArrayOutputStream baout = new ByteArrayOutputStream();
YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
Writer writer = new OutputStreamWriter(baout, "US-ASCII");
IOUtils.copy(in, writer, null);
out.off();
writer.flush();
assertEquals("Not all bytes were read", 0, in.available());
assertEquals("Sizes differ", inData.length, baout.size());
assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));