private void countAndCallListener(int written) {
    this.byteCount += written;
    if (byteCount == 0) {
      return;
    }

    byteCountListener.accept(byteCount);
    byteCount = 0;
  }
Wraps the {@code underlyingOutputStream} to count the bytes written.

@param underlyingOutputStream the wrapped {@link OutputStream}
@param byteCountListener the byte count {@link Consumer}
jib-core/src/main/java/com/google/cloud/tools/jib/http/NotifyingOutputStream.java