I don't understand this. The byteStream already tracks what you've written. That's what byteStream.getSize() returns. Why would you want to have some different, potentially wrong mechanism for tracking the size?