@ Override public void write ( byte [ ] b , int off , int len ) throws IOException { if ( currentEntry != null && ! currentEntry . isDirectory ( ) ) { if ( currentEntry . getSize ( ) < currentFileSize + len ) { throw new IOException ( "The current entry[" + currentEntry . getName ( ) + "] size[" + currentEntry . getSize ( ) + "] is smaller than the bytes[" + ( currentFileSize + len ) + "] being written." ) ; } } out . write ( b , off , len ) ; bytesWritten += len ; if ( currentEntry != null ) { currentFileSize += len ; } }
Checks if the bytes being written exceed the current entry size .