src/share/classes/java/util/zip/Deflater.java
Print this page
*** 77,86 ****
--- 77,88 ----
private byte[] buf = new byte[0];
private int off, len;
private int level, strategy;
private boolean setParams;
private boolean finish, finished;
+ private long bytesRead;
+ private long bytesWritten;
/**
* Compression method for the deflate algorithm (the only one currently
* supported).
*/
*** 421,432 ****
throw new ArrayIndexOutOfBoundsException();
}
synchronized (zsRef) {
ensureOpen();
if (flush == NO_FLUSH || flush == SYNC_FLUSH ||
! flush == FULL_FLUSH)
! return deflateBytes(zsRef.address(), b, off, len, flush);
throw new IllegalArgumentException();
}
}
/**
--- 423,439 ----
throw new ArrayIndexOutOfBoundsException();
}
synchronized (zsRef) {
ensureOpen();
if (flush == NO_FLUSH || flush == SYNC_FLUSH ||
! flush == FULL_FLUSH) {
! int thisLen = this.len;
! int n = deflateBytes(zsRef.address(), b, off, len, flush);
! bytesWritten += n;
! bytesRead += (thisLen - this.len);
! return n;
! }
throw new IllegalArgumentException();
}
}
/**
*** 460,470 ****
* @since 1.5
*/
public long getBytesRead() {
synchronized (zsRef) {
ensureOpen();
! return getBytesRead(zsRef.address());
}
}
/**
* Returns the total number of compressed bytes output so far.
--- 467,477 ----
* @since 1.5
*/
public long getBytesRead() {
synchronized (zsRef) {
ensureOpen();
! return bytesRead;
}
}
/**
* Returns the total number of compressed bytes output so far.
*** 486,496 ****
* @since 1.5
*/
public long getBytesWritten() {
synchronized (zsRef) {
ensureOpen();
! return getBytesWritten(zsRef.address());
}
}
/**
* Resets deflater so that a new set of input data can be processed.
--- 493,503 ----
* @since 1.5
*/
public long getBytesWritten() {
synchronized (zsRef) {
ensureOpen();
! return bytesWritten;
}
}
/**
* Resets deflater so that a new set of input data can be processed.
*** 501,510 ****
--- 508,518 ----
ensureOpen();
reset(zsRef.address());
finish = false;
finished = false;
off = len = 0;
+ bytesRead = bytesWritten = 0;
}
}
/**
* Closes the compressor and discards any unprocessed input.
*** 541,550 ****
private native static long init(int level, int strategy, boolean nowrap);
private native static void setDictionary(long addr, byte[] b, int off, int len);
private native int deflateBytes(long addr, byte[] b, int off, int len,
int flush);
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);
}
--- 549,556 ----