public static long getLengthOfParts ( final Part [ ] parts , final byte [ ] partBoundary ) throws IOException { if ( DEBUG ) { Log . v ( TAG , "getLengthOfParts(Parts[])" ) ; } if ( parts == null ) { throw new IllegalArgumentException ( "Parts may not be null" ) ; } long total = 0 ; for ( int i = 0 ; i < parts . length ; i ++ ) { // set the part boundary before we calculate the part's length parts [ i ] . setPartBoundary ( partBoundary ) ; final long l = parts [ i ] . length ( ) ; if ( l < 0 ) { return - 1 ; } total += l ; } total += EXTRA_BYTES . length ; total += partBoundary . length ; total += EXTRA_BYTES . length ; total += CRLF_BYTES . length ; return total ; }
Gets the length of the multipart message including the given parts .