question: public static boolean copyStream ( InputStream is , OutputStream os , CopyListener listener , int bufferSize ) throws IOException { int current = 0 ; final int total = is . available ( ) ; final byte [ ] bytes = new byte [ bufferSize ] ; int count ; if ( shouldStopLoading ( listener , current , total ) ) return false ; while ( ( count = is . read ( bytes , 0 , bufferSize ) ) != - 1 ) { os . write ( bytes , 0 , count ) ; current += count ; if ( shouldStopLoading ( listener , current , total ) ) return false ; } return true ; }
target:  Copies stream, fires progress events by listener, can be interrupted by listener.