public long length() throws IOException {
  LOG.trace("enter length()");
  if (lengthOfData() < 0) {
    return -1;
  }
  final ByteArrayOutputStream overhead=new ByteArrayOutputStream();
  sendStart(overhead);
  sendDispositionHeader(overhead);
  sendContentTypeHeader(overhead);
  sendTransferEncodingHeader(overhead);
  sendEndOfHeader(overhead);
  sendEnd(overhead);
  return overhead.size() + lengthOfData();
}

public long length ( ) throws IOException { LOG . trace ( "enter length()" ) ; if ( lengthOfData ( ) < 0 ) { return - 1 ; } final ByteArrayOutputStream overhead = new ByteArrayOutputStream ( ) ; sendStart ( overhead ) ; sendDispositionHeader ( overhead ) ; sendContentTypeHeader ( overhead ) ; sendTransferEncodingHeader ( overhead ) ; sendEndOfHeader ( overhead ) ; sendEnd ( overhead ) ; return overhead . size ( ) + lengthOfData ( ) ; }
return the full length of all the data . if you override this method make sure to override # send ( outputstream ) as well
