protected void writeBody ( HttpURLConnection connection , ProgressListener listener ) { if ( this . body == null ) { return ; } connection . setDoOutput ( true ) ; try { OutputStream output = connection . getOutputStream ( ) ; if ( listener != null ) { output = new ProgressOutputStream ( output , listener , this . bodyLength ) ; } int b = this . body . read ( ) ; while ( b != - 1 ) { output . write ( b ) ; b = this . body . read ( ) ; } output . close ( ) ; } catch ( IOException e ) { throw new BoxAPIException ( "Couldn't connect to the Box API due to a network error." , e ) ; } }
Writes the body of this request to an HttpURLConnection .