home *** CD-ROM | disk | FTP | other *** search
- package java.util.zip;
-
- import java.io.EOFException;
- import java.io.FilterInputStream;
- import java.io.IOException;
- import java.io.InputStream;
-
- public class InflaterInputStream extends FilterInputStream {
- protected Inflater inf;
- protected byte[] buf;
- protected int len;
- private boolean closed;
- private boolean reachEOF;
-
- private void ensureOpen() throws IOException {
- if (this.closed) {
- throw new IOException("Stream closed");
- }
- }
-
- public InflaterInputStream(InputStream var1, Inflater var2, int var3) {
- super(var1);
- this.closed = false;
- this.reachEOF = false;
- if (var1 != null && var2 != null) {
- if (var3 <= 0) {
- throw new IllegalArgumentException("buffer size <= 0");
- } else {
- this.inf = var2;
- this.buf = new byte[var3];
- }
- } else {
- throw new NullPointerException();
- }
- }
-
- public InflaterInputStream(InputStream var1, Inflater var2) {
- this(var1, var2, 512);
- }
-
- public InflaterInputStream(InputStream var1) {
- this(var1, new Inflater());
- }
-
- public int read() throws IOException {
- this.ensureOpen();
- byte[] var1 = new byte[1];
- return this.read(var1, 0, 1) == -1 ? -1 : var1[0] & 255;
- }
-
- public int read(byte[] var1, int var2, int var3) throws IOException {
- this.ensureOpen();
- if ((var2 | var3 | var2 + var3 | var1.length - (var2 + var3)) < 0) {
- throw new IndexOutOfBoundsException();
- } else if (var3 == 0) {
- return 0;
- } else {
- try {
- int var4;
- while((var4 = this.inf.inflate(var1, var2, var3)) == 0) {
- if (this.inf.finished() || this.inf.needsDictionary()) {
- this.reachEOF = true;
- return -1;
- }
-
- if (this.inf.needsInput()) {
- this.fill();
- }
- }
-
- return var4;
- } catch (DataFormatException var6) {
- String var5 = ((Throwable)var6).getMessage();
- throw new ZipException(var5 != null ? var5 : "Invalid ZLIB data format");
- }
- }
- }
-
- public int available() throws IOException {
- this.ensureOpen();
- return this.reachEOF ? 0 : 1;
- }
-
- public long skip(long var1) throws IOException {
- if (var1 < 0L) {
- throw new IllegalArgumentException("negative skip length");
- } else {
- this.ensureOpen();
- int var3 = (int)Math.min(var1, 2147483647L);
- int var4 = 0;
-
- int var7;
- for(byte[] var5 = new byte[512]; var4 < var3; var4 += var7) {
- var7 = var3 - var4;
- if (var7 > var5.length) {
- var7 = var5.length;
- }
-
- var7 = this.read(var5, 0, var7);
- if (var7 == -1) {
- this.reachEOF = true;
- break;
- }
- }
-
- return (long)var4;
- }
- }
-
- public void close() throws IOException {
- this.inf.end();
- super.in.close();
- this.closed = true;
- }
-
- protected void fill() throws IOException {
- this.ensureOpen();
- this.len = super.in.read(this.buf, 0, this.buf.length);
- if (this.len == -1) {
- throw new EOFException("Unexpected end of ZLIB input stream");
- } else {
- this.inf.setInput(this.buf, 0, this.len);
- }
- }
- }
-