src/share/classes/java/util/zip/Inflater.java
Print this page
*** 76,85 ****
--- 76,87 ----
private final ZStreamRef zsRef;
private byte[] buf = defaultBuf;
private int off, len;
private boolean finished;
private boolean needDict;
+ private long bytesRead;
+ private long bytesWritten;
private static final byte[] defaultBuf = new byte[0];
static {
/* Zip library is loaded from System.initializeSystemClass */
*** 251,261 ****
if (off < 0 || len < 0 || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
synchronized (zsRef) {
ensureOpen();
! return inflateBytes(zsRef.address(), b, off, len);
}
}
/**
* Uncompresses bytes into specified buffer. Returns actual number
--- 253,267 ----
if (off < 0 || len < 0 || off > b.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
synchronized (zsRef) {
ensureOpen();
! int thisLen = this.len;
! int n = inflateBytes(zsRef.address(), b, off, len);
! bytesWritten += n;
! bytesRead += (thisLen - this.len);
! return n;
}
}
/**
* Uncompresses bytes into specified buffer. Returns actual number
*** 305,315 ****
* @since 1.5
*/
public long getBytesRead() {
synchronized (zsRef) {
ensureOpen();
! return getBytesRead(zsRef.address());
}
}
/**
* Returns the total number of uncompressed bytes output so far.
--- 311,321 ----
* @since 1.5
*/
public long getBytesRead() {
synchronized (zsRef) {
ensureOpen();
! return bytesRead;
}
}
/**
* Returns the total number of uncompressed bytes output so far.
*** 331,341 ****
* @since 1.5
*/
public long getBytesWritten() {
synchronized (zsRef) {
ensureOpen();
! return getBytesWritten(zsRef.address());
}
}
/**
* Resets inflater so that a new set of input data can be processed.
--- 337,347 ----
* @since 1.5
*/
public long getBytesWritten() {
synchronized (zsRef) {
ensureOpen();
! return bytesWritten;
}
}
/**
* Resets inflater so that a new set of input data can be processed.
*** 346,355 ****
--- 352,362 ----
reset(zsRef.address());
buf = defaultBuf;
finished = false;
needDict = false;
off = len = 0;
+ bytesRead = bytesWritten = 0;
}
}
/**
* Closes the decompressor and discards any unprocessed input.
*** 393,402 ****
private native static void setDictionary(long addr, byte[] b, int off,
int len);
private native int inflateBytes(long addr, byte[] b, int off, int len)
throws DataFormatException;
private native static int getAdler(long addr);
- private native static long getBytesRead(long addr);
- private native static long getBytesWritten(long addr);
private native static void reset(long addr);
private native static void end(long addr);
}
--- 400,407 ----