code: public static long computeLength(StreamingContent content) throws IOException {
      ByteCountingOutputStream countingStream = new ByteCountingOutputStream();
      try {
        content.writeTo(countingStream);
      } finally {
        countingStream.close();
      }
      return countingStream.count;
    }
docs: Computes and returns the byte content length for a streaming content by calling {@link
  StreamingContent#writeTo(OutputStream)} on a fake output stream that only counts bytes written.
  
  @param content streaming content