src/share/classes/java/util/zip/ZipFile.java

Print this page
rev 4099 : 7041612: Rename StandardCharset to StandardCharsets
Reviewed-by: alanb, mr, darcy


  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.util.zip;
  27 
  28 import java.io.Closeable;
  29 import java.io.InputStream;
  30 import java.io.IOException;
  31 import java.io.EOFException;
  32 import java.io.File;
  33 import java.nio.charset.Charset;
  34 import java.nio.charset.StandardCharset;
  35 import java.util.ArrayDeque;
  36 import java.util.Deque;
  37 import java.util.Enumeration;
  38 import java.util.HashMap;
  39 import java.util.Map;
  40 import java.util.NoSuchElementException;
  41 import java.util.WeakHashMap;
  42 import java.security.AccessController;
  43 import sun.security.action.GetPropertyAction;
  44 import static java.util.zip.ZipConstants64.*;
  45 
  46 /**
  47  * This class is used to read entries from a zip file.
  48  *
  49  * <p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor
  50  * or method in this class will cause a {@link NullPointerException} to be
  51  * thrown.
  52  *
  53  * @author      David Connelly
  54  */


 124      * method is called with the <code>name</code> argument as its argument to
 125      * ensure the read is allowed.
 126      *
 127      * <p>The UTF-8 {@link java.nio.charset.Charset charset} is used to
 128      * decode the entry names and comments
 129      *
 130      * @param file the ZIP file to be opened for reading
 131      * @param mode the mode in which the file is to be opened
 132      * @throws ZipException if a ZIP format error has occurred
 133      * @throws IOException if an I/O error has occurred
 134      * @throws SecurityException if a security manager exists and
 135      *         its <code>checkRead</code> method
 136      *         doesn't allow read access to the file,
 137      *         or its <code>checkDelete</code> method doesn't allow deleting
 138      *         the file when the <tt>OPEN_DELETE</tt> flag is set.
 139      * @throws IllegalArgumentException if the <tt>mode</tt> argument is invalid
 140      * @see SecurityManager#checkRead(java.lang.String)
 141      * @since 1.3
 142      */
 143     public ZipFile(File file, int mode) throws IOException {
 144         this(file, mode, StandardCharset.UTF_8);
 145     }
 146 
 147     /**
 148      * Opens a ZIP file for reading given the specified File object.
 149      *
 150      * <p>The UTF-8 {@link java.nio.charset.Charset charset} is used to
 151      * decode the entry names and comments.
 152      *
 153      * @param file the ZIP file to be opened for reading
 154      * @throws ZipException if a ZIP format error has occurred
 155      * @throws IOException if an I/O error has occurred
 156      */
 157     public ZipFile(File file) throws ZipException, IOException {
 158         this(file, OPEN_READ);
 159     }
 160 
 161     private ZipCoder zc;
 162 
 163     /**
 164      * Opens a new <code>ZipFile</code> to read from the specified




  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.util.zip;
  27 
  28 import java.io.Closeable;
  29 import java.io.InputStream;
  30 import java.io.IOException;
  31 import java.io.EOFException;
  32 import java.io.File;
  33 import java.nio.charset.Charset;
  34 import java.nio.charset.StandardCharsets;
  35 import java.util.ArrayDeque;
  36 import java.util.Deque;
  37 import java.util.Enumeration;
  38 import java.util.HashMap;
  39 import java.util.Map;
  40 import java.util.NoSuchElementException;
  41 import java.util.WeakHashMap;
  42 import java.security.AccessController;
  43 import sun.security.action.GetPropertyAction;
  44 import static java.util.zip.ZipConstants64.*;
  45 
  46 /**
  47  * This class is used to read entries from a zip file.
  48  *
  49  * <p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor
  50  * or method in this class will cause a {@link NullPointerException} to be
  51  * thrown.
  52  *
  53  * @author      David Connelly
  54  */


 124      * method is called with the <code>name</code> argument as its argument to
 125      * ensure the read is allowed.
 126      *
 127      * <p>The UTF-8 {@link java.nio.charset.Charset charset} is used to
 128      * decode the entry names and comments
 129      *
 130      * @param file the ZIP file to be opened for reading
 131      * @param mode the mode in which the file is to be opened
 132      * @throws ZipException if a ZIP format error has occurred
 133      * @throws IOException if an I/O error has occurred
 134      * @throws SecurityException if a security manager exists and
 135      *         its <code>checkRead</code> method
 136      *         doesn't allow read access to the file,
 137      *         or its <code>checkDelete</code> method doesn't allow deleting
 138      *         the file when the <tt>OPEN_DELETE</tt> flag is set.
 139      * @throws IllegalArgumentException if the <tt>mode</tt> argument is invalid
 140      * @see SecurityManager#checkRead(java.lang.String)
 141      * @since 1.3
 142      */
 143     public ZipFile(File file, int mode) throws IOException {
 144         this(file, mode, StandardCharsets.UTF_8);
 145     }
 146 
 147     /**
 148      * Opens a ZIP file for reading given the specified File object.
 149      *
 150      * <p>The UTF-8 {@link java.nio.charset.Charset charset} is used to
 151      * decode the entry names and comments.
 152      *
 153      * @param file the ZIP file to be opened for reading
 154      * @throws ZipException if a ZIP format error has occurred
 155      * @throws IOException if an I/O error has occurred
 156      */
 157     public ZipFile(File file) throws ZipException, IOException {
 158         this(file, OPEN_READ);
 159     }
 160 
 161     private ZipCoder zc;
 162 
 163     /**
 164      * Opens a new <code>ZipFile</code> to read from the specified