Пример #1
0
 public ZOutputStream(OutputStream out) throws IOException {
   super(out);
   this.out = out;
   inflater = new Inflater();
   inflater.init();
   compress = false;
 }
Пример #2
0
 public void write(byte b[], int off, int len) throws IOException {
   if (len == 0) return;
   if (compress) {
     dos.write(b, off, len);
   } else {
     inflater.setInput(b, off, len, true);
     int err = JZlib.Z_OK;
     while (inflater.avail_in > 0) {
       inflater.setOutput(buf, 0, buf.length);
       err = inflater.inflate(flush);
       if (inflater.next_out_index > 0) out.write(buf, 0, inflater.next_out_index);
       if (err != JZlib.Z_OK) break;
     }
     if (err != JZlib.Z_OK) throw new ZStreamException("inflating: " + inflater.msg);
     return;
   }
 }
Пример #3
0
 public synchronized void end() {
   if (end) return;
   if (compress) {
     try {
       dos.finish();
     } catch (Exception e) {
     }
   } else {
     inflater.end();
   }
   end = true;
 }