private void manageInputWriterChannel() throws InterruptedException {


        try {

            ByteBuffer dataToWriteToFile;
            dataToWriteToFile = inputChannel.poll();  //no wait

            //If it is null, it means the inputChannel is empty and we need to flush.
            if (dataToWriteToFile == null) {
                queueEmptyMaybeFlush();
                dataToWriteToFile = inputChannel.poll();
            }


            //If it is still null, this means that we need to wait
            //for more items to show up in the inputChannel.
            if (dataToWriteToFile == null) {
                dataToWriteToFile = waitForNextDataToWrite();
            }

            //We have to check for null again because we could have been interrupted.
            if (dataToWriteToFile != null) {
                //Write it
                writer.nextBufferToWrite(dataToWriteToFile);
                //Then give it back
                if (RECYCLE_BUFFER) {
                    recycleChannel.offer(dataToWriteToFile);
                }

            }

        } catch (InterruptedException ex) {
            throw ex;
        } catch (Exception ex) {
            ex.printStackTrace();
            ex.printStackTrace(System.err);
        }

    }
private void manageInputWriterChannel() throws InterruptedException {


        try {

            ByteBuffer dataToWriteToFile;
            dataToWriteToFile = inputChannel.poll();  

            
            if (dataToWriteToFile == null) {
                queueEmptyMaybeFlush();
                dataToWriteToFile = inputChannel.poll();
            }


            
            
            if (dataToWriteToFile == null) {
                dataToWriteToFile = waitForNextDataToWrite();
            }

            
            if (dataToWriteToFile != null) {
                
                writer.nextBufferToWrite(dataToWriteToFile);
                
                if (RECYCLE_BUFFER) {
                    recycleChannel.offer(dataToWriteToFile);
                }

            }

        } catch (InterruptedException ex) {
            throw ex;
        } catch (Exception ex) {
            ex.printStackTrace();
            ex.printStackTrace(System.err);
        }

    }
private void manageInputWriterChannel ( ) throws InterruptedException { try { ByteBuffer dataToWriteToFile ; dataToWriteToFile = inputChannel . poll ( ) ; //no wait //If it is null, it means the inputChannel is empty and we need to flush. if ( dataToWriteToFile == null ) { queueEmptyMaybeFlush ( ) ; dataToWriteToFile = inputChannel . poll ( ) ; } //If it is still null, this means that we need to wait //for more items to show up in the inputChannel. if ( dataToWriteToFile == null ) { dataToWriteToFile = waitForNextDataToWrite ( ) ; } //We have to check for null again because we could have been interrupted. if ( dataToWriteToFile != null ) { //Write it writer . nextBufferToWrite ( dataToWriteToFile ) ; //Then give it back if ( RECYCLE_BUFFER ) { recycleChannel . offer ( dataToWriteToFile ) ; } } } catch ( InterruptedException ex ) { throw ex ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; ex . printStackTrace ( System . err ) ; } }
Queue and batch writer main logic.
This is where the magic happens.

@throws InterruptedException
Queue and batch writer main logic . This is where the magic happens .