jdk/src/share/classes/java/util/zip/ZipFile.java
changeset 3078 c491f0d2a8aa
parent 2915 92e31faf9ffc
child 3849 34469964aa98
--- a/jdk/src/share/classes/java/util/zip/ZipFile.java	Mon Jun 29 15:08:52 2009 +0100
+++ b/jdk/src/share/classes/java/util/zip/ZipFile.java	Mon Jun 29 19:57:58 2009 -0700
@@ -25,6 +25,7 @@
 
 package java.util.zip;
 
+import java.io.Closeable;
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.EOFException;
@@ -47,7 +48,7 @@
  * @author      David Connelly
  */
 public
-class ZipFile implements ZipConstants {
+class ZipFile implements ZipConstants, Closeable {
     private long jzfile;  // address of jzfile data
     private String name;  // zip file name
     private int total;    // total number of entries
@@ -249,6 +250,25 @@
     }
 
     /**
+     * Returns the zip file comment, or null if none.
+     *
+     * @return the comment string for the zip file, or null if none
+     *
+     * @throws IllegalStateException if the zip file has been closed
+     *
+     * Since 1.7
+     */
+    public String getComment() {
+        synchronized (this) {
+            ensureOpen();
+            byte[] bcomm = getCommentBytes(jzfile);
+            if (bcomm == null)
+                return null;
+            return zc.toString(bcomm, bcomm.length);
+        }
+    }
+
+    /**
      * Returns the zip file entry for the specified name, or null
      * if not found.
      *
@@ -663,6 +683,7 @@
     private static native long getEntrySize(long jzentry);
     private static native int getEntryMethod(long jzentry);
     private static native int getEntryFlag(long jzentry);
+    private static native byte[] getCommentBytes(long jzfile);
 
     private static final int JZENTRY_NAME = 0;
     private static final int JZENTRY_EXTRA = 1;