sclass JustCountingOutputStream extends OutputStream { long counter; @Override public void write(int b) throws IOException { ++counter; } @Override public void write(byte[] b) throws IOException { counter += b.length; } @Override public void write(byte[] b, int off, int len) throws IOException { counter += len; } long getFilePointer aka get() { ret counter; } }