@ Override public void offerData ( OutputStream stream ) { byte [ ] next = null ; try { next = queue . poll ( timeoutMillis , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException ignored ) { // If this ever times out (unlikely given our assumption), next stays null. } try { // Only if next is not null nor CLOSED do we write the chunk. if ( next != null && next != CLOSED ) { stream . write ( next ) ; return ; } } catch ( IOException ignored ) { // Any errors in the piped (NS)OutputStream (unlikely) fall through to the next section. } // Close the piped (NS)OutputStream and ignore any errors. try { stream . close ( ) ; } catch ( IOException ignored ) { // Ignored. } }
Offers data from the queue to the OutputStream piped to the adapted NSInputStream .