@ Override protected void sendData ( final OutputStream out ) throws IOException { if ( DEBUG ) { Log . v ( TAG , "enter sendData(OutputStream out)" ) ; } if ( lengthOfData ( ) == 0 ) { // this file contains no data, so there is nothing to send. // we don't want to create a zero length buffer as this will // cause an infinite loop when reading. if ( DEBUG ) { Log . d ( TAG , "No data to send." ) ; } return ; } final int size = 4096 ; final byte [ ] tmp = new byte [ size ] ; final InputStream instream = source . createInputStream ( ) ; try { int len ; while ( ( len = instream . read ( tmp ) ) >= 0 ) { out . write ( tmp , 0 , len ) ; } } finally { // we're done with the stream, close it instream . close ( ) ; } }
Write the data in source to the specified stream .