Avoiding API Methods with Implicit Object Allocations
byteStream.getByteArray();
private byte[] buffer = new byte[5000];
private MyByteArrayOutputStream byteStream = new MyByteArrayOutputStream();
public byte[] readIntoBuffer(InputStream in) throws IOException {
bytesRead = in.read(buffer);
byteStream.write(buffer, 0, bytesRead);
return byteStream.getByteArray();
Slide 30