byte[] buffer = "1234567890".getBytes("UTF-8");
BufferedOutputStream buffos = new BufferedOutputStream(byteArrayos, 10);
buffos.write(buffer, 0, 10);
byteArrayis = new ByteArrayInputStream(byteArrayos.toByteArray());
assertEquals("Bytes written, not buffered", 10, byteArrayis.available());
buffos.flush();
byteArrayis = new ByteArrayInputStream(byteArrayos.toByteArray());
assertEquals("Bytes not written after flush", 10, byteArrayis
.available());
for (int i = 0; i < 10; i++) {