public void finish() throws IOException {
  if (!def.finished()) {
    def.finish();
    while (!def.finished()) {
      int len=def.deflate(buf,0,buf.length);
      if (def.finished() && len <= buf.length - TRAILER_SIZE) {
        writeTrailer(buf,len);
        len=len + TRAILER_SIZE;
        totalLength+=TRAILER_SIZE;
        out.write(buf,0,len);
        return;
      }
      if (len > 0) {
        out.write(buf,0,len);
      }
    }
    byte[] trailer=new byte[TRAILER_SIZE];
    writeTrailer(trailer,0);
    out.write(trailer);
    totalLength+=TRAILER_SIZE;
  }
}

public void finish ( ) throws IOException { if ( ! def . finished ( ) ) { def . finish ( ) ; while ( ! def . finished ( ) ) { int len = def . deflate ( buf , 0 , buf . length ) ; if ( def . finished ( ) && len <= buf . length - TRAILER_SIZE ) { writeTrailer ( buf , len ) ; len = len + TRAILER_SIZE ; totalLength += TRAILER_SIZE ; out . write ( buf , 0 , len ) ; return ; } if ( len > 0 ) { out . write ( buf , 0 , len ) ; } } byte [ ] trailer = new byte [ TRAILER_SIZE ] ; writeTrailer ( trailer , 0 ) ; out . write ( trailer ) ; totalLength += TRAILER_SIZE ; } }
finishes writing compressed data to the output stream without closing the underlying stream . use this method when applying multiple filters in succession to the same output stream .
