Index: java/util/zip/DeflaterOutputStream.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/util/zip/DeflaterOutputStream.java,v retrieving revision 1.6 diff -u -b -B -r1.6 DeflaterOutputStream.java --- java/util/zip/DeflaterOutputStream.java 12 Apr 2004 12:30:57 -0000 1.6 +++ java/util/zip/DeflaterOutputStream.java 15 Jun 2004 10:35:53 -0000 @@ -76,7 +76,7 @@ * def.deflate() until all bytes from the input buffers * are processed. */ - protected void deflate () throws IOException + protected void deflate() throws IOException { while (! def.needsInput()) { @@ -97,9 +97,9 @@ * default buffer size. * @param out the output stream where deflated output should be written. */ - public DeflaterOutputStream (OutputStream out) + public DeflaterOutputStream(OutputStream out) { - this (out, new Deflater (), 512); + this(out, new Deflater(), 512); } /** @@ -108,9 +108,9 @@ * @param out the output stream where deflated output should be written. * @param defl the underlying deflater. */ - public DeflaterOutputStream (OutputStream out, Deflater defl) + public DeflaterOutputStream(OutputStream out, Deflater defl) { - this (out, defl, 512); + this(out, defl, 512); } /** @@ -123,7 +123,7 @@ */ public DeflaterOutputStream(OutputStream out, Deflater defl, int bufsize) { - super (out); + super(out); if (bufsize <= 0) throw new IllegalArgumentException("bufsize <= 0"); buf = new byte[bufsize]; @@ -148,10 +148,10 @@ * was the only way to ensure that all bytes are flushed in Sun's * JDK. */ - public void finish () throws IOException + public void finish() throws IOException { def.finish(); - while (! def.finished ()) + while (! def.finished()) { int len = def.deflate(buf, 0, buf.length); if (len <= 0) @@ -164,7 +164,7 @@ } /** - * Calls finish () and closes the stream. + * Calls finish() and closes the stream. */ public void close() throws IOException { Index: java/util/zip/InflaterInputStream.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/util/zip/InflaterInputStream.java,v retrieving revision 1.12 diff -u -b -B -r1.12 InflaterInputStream.java --- java/util/zip/InflaterInputStream.java 30 Apr 2004 19:21:35 -0000 1.12 +++ java/util/zip/InflaterInputStream.java 15 Jun 2004 10:35:53 -0000 @@ -109,14 +109,13 @@ public InflaterInputStream(InputStream in, Inflater inf, int size) { super(in); - this.len = 0; if (in == null) - throw new NullPointerException ("in may not be null"); + throw new NullPointerException("in may not be null"); if (inf == null) - throw new NullPointerException ("inf may not be null"); + throw new NullPointerException("inf may not be null"); if (size < 0) - throw new IllegalArgumentException ("size may not be negative"); + throw new IllegalArgumentException("size may not be negative"); this.inf = inf; this.buf = new byte [size]; @@ -130,6 +129,8 @@ { // According to the JDK 1.2 docs, this should only ever return 0 // or 1 and should not be relied upon by Java programs. + if (inf == null) + throw new IOException("stream closed"); return inf.finished() ? 0 : 1; } @@ -183,12 +184,14 @@ */ public int read(byte[] b, int off, int len) throws IOException { + if (inf == null) + throw new IOException("stream closed"); if (len == 0) return 0; + int count = 0; for (;;) { - int count; try { @@ -219,27 +222,28 @@ */ public long skip(long n) throws IOException { + if (inf == null) + throw new IOException("stream closed"); if (n < 0) throw new IllegalArgumentException(); if (n == 0) return 0; - // Implementation copied from InputStream - // Throw away n bytes by reading them into a temp byte[]. - // Limit the temp array to 2Kb so we don't grab too much memory. - final int buflen = n > 2048 ? 2048 : (int) n; + int buflen = (int) Math.min(n, 2048); byte[] tmpbuf = new byte[buflen]; - final long origN = n; + long skipped = 0L; while (n > 0L) { - int numread = read(tmpbuf, 0, n > buflen ? buflen : (int) n); + int numread = read(tmpbuf, 0, buflen); if (numread <= 0) break; n -= numread; + skipped += numread; + buflen = (int) Math.min(n, 2048); } - return origN - n; + return skipped; } }