diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-17 20:44:03 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-17 20:44:03 +0000 |
commit | 580b82bc48703ed0f56f3c2534b0a7294cabd7e6 (patch) | |
tree | 0ca710082c0fee778050b7a6372e10201f7c22aa /libjava/java/util | |
parent | 469ea67a3296430eb9039a155063191b9f62cc28 (diff) | |
download | gcc-580b82bc48703ed0f56f3c2534b0a7294cabd7e6.tar.gz |
* java/text/CollationKey.java: Implement Comparable.
(compareTo(Object)): New method.
* java/text/Collator.java (compare(Object,Object)): New method.
Implement Comparator.
* java/util/zip/InflaterInputStream.java (available): New method.
(close): New method.
(read, available, skip, fill): Throw exception if stream closed.
* java/util/zip/ZipInputStream.java (read, skip, readFully, fill,
getNextEntry): Throw exception if closed.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37525 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/util')
-rw-r--r-- | libjava/java/util/zip/InflaterInputStream.java | 24 | ||||
-rw-r--r-- | libjava/java/util/zip/ZipInputStream.java | 18 |
2 files changed, 35 insertions, 7 deletions
diff --git a/libjava/java/util/zip/InflaterInputStream.java b/libjava/java/util/zip/InflaterInputStream.java index e09f208349a..3db1b2a1eb3 100644 --- a/libjava/java/util/zip/InflaterInputStream.java +++ b/libjava/java/util/zip/InflaterInputStream.java @@ -1,6 +1,6 @@ // InflaterInputStream.java - Input stream filter for decompressing. -/* Copyright (C) 1999 Free Software Foundation +/* Copyright (C) 1999, 2000 Free Software Foundation This file is part of libgcj. @@ -28,6 +28,8 @@ public class InflaterInputStream extends FilterInputStream { protected void fill () throws IOException { + if (inf == null) + throw new IOException ("stream closed"); len = in.read(buf, 0, buf.length); if (len != -1) inf.setInput(buf, 0, len); @@ -61,6 +63,8 @@ public class InflaterInputStream extends FilterInputStream public int read (byte[] buf, int off, int len) throws IOException { + if (inf == null) + throw new IOException ("stream closed"); if (inf.finished()) return -1; if (inf.needsInput()) @@ -79,8 +83,26 @@ public class InflaterInputStream extends FilterInputStream } } + public void close () throws IOException + { + inf = null; + super.close (); + } + + public int available () throws IOException + { + // 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; + } + public long skip (long n) throws IOException { + if (inf == null) + throw new IOException ("stream closed"); + if (n == 0) return 0; diff --git a/libjava/java/util/zip/ZipInputStream.java b/libjava/java/util/zip/ZipInputStream.java index 79efb59f06c..b50cc7be592 100644 --- a/libjava/java/util/zip/ZipInputStream.java +++ b/libjava/java/util/zip/ZipInputStream.java @@ -35,6 +35,8 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants public ZipEntry getNextEntry () throws IOException { + if (closed) + throw new IOException ("stream closed"); if (current != null) closeEntry(); if (in.read() != 'P' @@ -112,6 +114,8 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants // back data. protected void fill () throws IOException { + if (closed) + throw new IOException ("stream closed"); int count = buf.length; if (count > compressed_bytes) count = compressed_bytes; @@ -127,9 +131,11 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants { return new ZipEntry (name); } - + public int read (byte[] b, int off, int len) throws IOException { + if (closed) + throw new IOException ("stream closed"); if (len > avail) len = avail; int count; @@ -149,6 +155,8 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants public long skip (long n) throws IOException { + if (closed) + throw new IOException ("stream closed"); if (n > avail) n = avail; long count; @@ -160,11 +168,9 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants return count; } - public int available() { - if (closed) - return 0; - else - return 1; + public int available() + { + return closed ? 0 : 1; } private void readFully (byte[] b) throws IOException |