public void flush() throws IOException {
    if (syncFlush && !deflater.finished()) {
      while (true) {
        int err = deflate(JZlib.Z_SYNC_FLUSH);
        if (deflater.next_out_index < buffer.length)
          break;
        if (err == JZlib.Z_STREAM_END)
          break;
      }
    }
    out.flush();
  }