annotate app/src/main/java/com/jcraft/jzlib/ZOutputStream.java @ 438:d29cce60f393

migrate from Eclipse to Android Studio
author Carl Byington <carl@five-ten-sg.com>
date Thu, 03 Dec 2015 11:23:55 -0800
parents src/com/jcraft/jzlib/ZOutputStream.java@46c2115ae1c8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1 /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2 /*
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
3 Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved.
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
4
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
5 Redistribution and use in source and binary forms, with or without
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
6 modification, are permitted provided that the following conditions are met:
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
7
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
8 1. Redistributions of source code must retain the above copyright notice,
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
9 this list of conditions and the following disclaimer.
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
10
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
11 2. Redistributions in binary form must reproduce the above copyright
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
12 notice, this list of conditions and the following disclaimer in
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
13 the documentation and/or other materials provided with the distribution.
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
14
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
15 3. The names of the authors may not be used to endorse or promote products
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
16 derived from this software without specific prior written permission.
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
17
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
18 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
19 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
20 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
21 INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
22 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
24 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
25 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
27 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
28 */
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
29
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
30 package com.jcraft.jzlib;
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
31 import java.io.*;
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
32
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
33 /**
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
34 * ZOutputStream
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
35 *
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
36 * @deprecated use DeflaterOutputStream or InflaterInputStream
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
37 */
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
38 @Deprecated
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
39 public class ZOutputStream extends FilterOutputStream {
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
40
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
41 protected int bufsize=512;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
42 protected int flush=JZlib.Z_NO_FLUSH;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
43 protected byte[] buf=new byte[bufsize];
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
44 protected boolean compress;
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
45
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
46 protected OutputStream out;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
47 private boolean end=false;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
48
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
49 private DeflaterOutputStream dos;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
50 private Inflater inflater;
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
51
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
52 public ZOutputStream(OutputStream out) throws IOException {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
53 super(out);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
54 this.out=out;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
55 inflater = new Inflater();
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
56 inflater.init();
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
57 compress=false;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
58 }
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
59
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
60 public ZOutputStream(OutputStream out, int level) throws IOException {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
61 this(out, level, false);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
62 }
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
63
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
64 public ZOutputStream(OutputStream out, int level, boolean nowrap) throws IOException {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
65 super(out);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
66 this.out=out;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
67 Deflater deflater = new Deflater(level, nowrap);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
68 dos = new DeflaterOutputStream(out, deflater);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
69 compress=true;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
70 }
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
71
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
72 private byte[] buf1 = new byte[1];
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
73 public void write(int b) throws IOException {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
74 buf1[0]=(byte)b;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
75 write(buf1, 0, 1);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
76 }
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
77
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
78 public void write(byte b[], int off, int len) throws IOException {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
79 if(len==0) return;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
80 if(compress){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
81 dos.write(b, off, len);
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
82 }
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
83 else {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
84 inflater.setInput(b, off, len, true);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
85 int err = JZlib.Z_OK;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
86 while(inflater.avail_in>0){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
87 inflater.setOutput(buf, 0, buf.length);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
88 err = inflater.inflate(flush);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
89 if(inflater.next_out_index>0)
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
90 out.write(buf, 0, inflater.next_out_index);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
91 if(err != JZlib.Z_OK)
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
92 break;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
93 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
94 if(err != JZlib.Z_OK)
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
95 throw new ZStreamException("inflating: "+inflater.msg);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
96 return;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
97 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
98 }
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
99
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
100 public int getFlushMode() {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
101 return flush;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
102 }
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
103
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
104 public void setFlushMode(int flush) {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
105 this.flush=flush;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
106 }
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
107
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
108 public void finish() throws IOException {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
109 int err;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
110 if(compress){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
111 int tmp = flush;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
112 int flush = JZlib.Z_FINISH;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
113 try{
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
114 write("".getBytes(), 0, 0);
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
115 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
116 finally { flush = tmp; }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
117 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
118 else{
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
119 dos.finish();
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
120 }
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
121 flush();
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
122 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
123 public synchronized void end() {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
124 if(end) return;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
125 if(compress){
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
126 try { dos.finish(); } catch(Exception e){}
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
127 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
128 else{
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
129 inflater.end();
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
130 }
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
131 end=true;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
132 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
133 public void close() throws IOException {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
134 try{
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
135 try{finish();}
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
136 catch (IOException ignored) {}
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
137 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
138 finally{
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
139 end();
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
140 out.close();
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
141 out=null;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
142 }
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
143 }
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
144
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
145 public long getTotalIn() {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
146 if(compress) return dos.getTotalIn();
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
147 else return inflater.total_in;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
148 }
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
149
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
150 public long getTotalOut() {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
151 if(compress) return dos.getTotalOut();
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
152 else return inflater.total_out;
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
153 }
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
154
357
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
155 public void flush() throws IOException {
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
156 out.flush();
46c2115ae1c8 update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
157 }
0
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
158
0ce5cc452d02 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
159 }