private void writeByChunk ( final byte [ ] bytes ) throws IOException { final int chunkSize = this . chunkSize ; if ( bytes . length == 0 ) { return ; } if ( chunkSize < bytes . length && chunkSize > 0 ) { int remaining = bytes . length ; int offset = 0 ; while ( remaining > 0 ) { if ( chunkSize < remaining ) { os . write ( bytes , offset , chunkSize ) ; remaining -= chunkSize ; offset += chunkSize ; } else { os . write ( bytes , offset , remaining ) ; remaining = 0 ; } } } else { os . write ( bytes ) ; } }
writes maximum bytes at chuckSize