diff options
| author | Mark Wielaard <mark@klomp.org> | 2004-06-26 11:37:28 +0000 |
|---|---|---|
| committer | Mark Wielaard <mark@klomp.org> | 2004-06-26 11:37:28 +0000 |
| commit | 755c1990e0d5a86bb89deb4f76c6fd2bc55852be (patch) | |
| tree | f900f7fd57445c168dd574f8a0a547d79ec7f535 /java/util/zip/ZipFile.java | |
| parent | 66528b41a0ba7ada184b4bc0dcc94e9d061813ec (diff) | |
| download | classpath-755c1990e0d5a86bb89deb4f76c6fd2bc55852be.tar.gz | |
2004-06-25 Anthony Green <green@redhat.com>
* java/util/zip/ZipFile.java (getInputStream): Return null if
entry not found.
Diffstat (limited to 'java/util/zip/ZipFile.java')
| -rw-r--r-- | java/util/zip/ZipFile.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/java/util/zip/ZipFile.java b/java/util/zip/ZipFile.java index 50f489fdb..25b578543 100644 --- a/java/util/zip/ZipFile.java +++ b/java/util/zip/ZipFile.java @@ -408,8 +408,18 @@ public class ZipFile implements ZipConstants * uncompressed data. Normally zip entry should be an entry * returned by getEntry() or entries(). * + * This implementation returns null if the requested entry does not + * exist. This decision is not obviously correct, however, it does + * appear to mirror Sun's implementation, and it is consistant with + * their javadoc. On the other hand, the old JCL book, 2nd Edition, + * claims that this should return a "non-null ZIP entry". We have + * chosen for now ignore the old book, as modern versions of Ant (an + * important application) depend on this behaviour. See discussion + * in this thread: + * http://gcc.gnu.org/ml/java-patches/2004-q2/msg00602.html + * * @param entry the entry to create an InputStream for. - * @return the input stream. + * @return the input stream, or null if the requested entry does not exist. * * @exception IOException if a i/o error occured. * @exception ZipException if the Zip archive is malformed. @@ -420,7 +430,7 @@ public class ZipFile implements ZipConstants String name = entry.getName(); ZipEntry zipEntry = (ZipEntry) entries.get(name); if (zipEntry == null) - throw new NoSuchElementException(name); + return null; long start = checkLocalHeader(zipEntry); int method = zipEntry.getMethod(); |
