home *** CD-ROM | disk | FTP | other *** search
- package java.util.zip;
-
- import java.io.FilterOutputStream;
- import java.io.IOException;
- import java.io.OutputStream;
-
- public class DeflaterOutputStream extends FilterOutputStream {
- protected Deflater def;
- protected byte[] buf;
-
- public DeflaterOutputStream(OutputStream var1, Deflater var2, int var3) {
- super(var1);
- this.def = var2;
- this.buf = new byte[var3];
- }
-
- public DeflaterOutputStream(OutputStream var1, Deflater var2) {
- this(var1, var2, 512);
- }
-
- public DeflaterOutputStream(OutputStream var1) {
- this(var1, new Deflater());
- }
-
- public void write(int var1) throws IOException {
- byte[] var2 = new byte[]{(byte)(var1 & 255)};
- this.write(var2, 0, 1);
- }
-
- public void write(byte[] var1, int var2, int var3) throws IOException {
- if (this.def.finished()) {
- throw new IOException("write beyond end of stream");
- } else {
- if (!this.def.finished()) {
- this.def.setInput(var1, var2, var3);
-
- while(!this.def.needsInput()) {
- this.deflate();
- }
- }
-
- }
- }
-
- public void finish() throws IOException {
- if (!this.def.finished()) {
- this.def.finish();
-
- while(!this.def.finished()) {
- this.deflate();
- }
- }
-
- }
-
- public void close() throws IOException {
- this.finish();
- super.out.close();
- }
-
- protected void deflate() throws IOException {
- int var1 = this.def.deflate(this.buf, 0, this.buf.length);
- if (var1 > 0) {
- super.out.write(this.buf, 0, var1);
- }
-
- }
- }
-