Methods Summary |
---|
public int | available()Returns 0 after EOF has been reached, otherwise always return 1.
Programs should not count on this method to return the actual number
of bytes that could be read without blocking.
ensureOpen();
if (reachEOF) {
return 0;
} else {
return 1;
}
|
public void | close()Closes this input stream and releases any system resources associated
with the stream.
if (!closed) {
if (usesDefaultInflater)
inf.end();
in.close();
closed = true;
}
|
private void | ensureOpen()Check to make sure that this stream has not been closed
if (closed) {
throw new IOException("Stream closed");
}
|
protected void | fill()Fills input buffer with more data to decompress.
ensureOpen();
len = in.read(buf, 0, buf.length);
if (len == -1) {
throw new EOFException("Unexpected end of ZLIB input stream");
}
inf.setInput(buf, 0, len);
|
public synchronized void | mark(int readlimit)Marks the current position in this input stream.
The mark method of InflaterInputStream
does nothing.
|
public boolean | markSupported()Tests if this input stream supports the mark and
reset methods. The markSupported
method of InflaterInputStream returns
false .
return false;
|
public int | read()Reads a byte of uncompressed data. This method will block until
enough input is available for decompression.
ensureOpen();
return read(singleByteBuf, 0, 1) == -1 ? -1 : singleByteBuf[0] & 0xff;
|
public int | read(byte[] b, int off, int len)Reads uncompressed data into an array of bytes. This method will
block until some input can be decompressed.
ensureOpen();
if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return 0;
}
try {
int n;
while ((n = inf.inflate(b, off, len)) == 0) {
if (inf.finished() || inf.needsDictionary()) {
reachEOF = true;
return -1;
}
if (inf.needsInput()) {
fill();
}
}
return n;
} catch (DataFormatException e) {
String s = e.getMessage();
throw new ZipException(s != null ? s : "Invalid ZLIB data format");
}
|
public synchronized void | reset()Repositions this stream to the position at the time the
mark method was last called on this input stream.
The method reset for class
InflaterInputStream does nothing except throw an
IOException .
throw new IOException("mark/reset not supported");
|
public long | skip(long n)Skips specified number of bytes of uncompressed data.
if (n < 0) {
throw new IllegalArgumentException("negative skip length");
}
ensureOpen();
int max = (int)Math.min(n, Integer.MAX_VALUE);
int total = 0;
while (total < max) {
int len = max - total;
if (len > b.length) {
len = b.length;
}
len = read(b, 0, len);
if (len == -1) {
reachEOF = true;
break;
}
total += len;
}
return total;
|