private void setup ( ) { try { this . partBoundary = ( "--" + boundary ) . getBytes ( "UTF-8" ) ; this . trailingBoundary = ( "--" + boundary + "--" ) . getBytes ( "UTF-8" ) ; this . contentType = "content-type: application/json" . getBytes ( "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } attachments = new ArrayList < Attachment > ( ) ; // some preamble contentLength += partBoundary . length ; contentLength += 6 ; // 3 * crlf contentLength += contentType . length ; // although we haven't added it yet, account for the trailing boundary contentLength += 2 ; // crlf contentLength += trailingBoundary . length ; }
common constructor stuff