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.util.ArrayDeque;
35 import java.util.Deque;
36 import java.util.Enumeration;
37 import java.util.HashMap;
38 import java.util.Map;
39 import java.util.NoSuchElementException;
40 import java.util.WeakHashMap;
41 import java.security.AccessController;
42 import sun.security.action.GetPropertyAction;
43 import static java.util.zip.ZipConstants64.*;
44
45 /**
46 * This class is used to read entries from a zip file.
47 *
48 * <p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor
49 * or method in this class will cause a {@link NullPointerException} to be
50 * thrown.
51 *
52 * @author David Connelly
53 */
123 * method is called with the <code>name</code> argument as its argument to
124 * ensure the read is allowed.
125 *
126 * <p>The UTF-8 {@link java.nio.charset.Charset charset} is used to
127 * decode the entry names and comments
128 *
129 * @param file the ZIP file to be opened for reading
130 * @param mode the mode in which the file is to be opened
131 * @throws ZipException if a ZIP format error has occurred
132 * @throws IOException if an I/O error has occurred
133 * @throws SecurityException if a security manager exists and
134 * its <code>checkRead</code> method
135 * doesn't allow read access to the file,
136 * or its <code>checkDelete</code> method doesn't allow deleting
137 * the file when the <tt>OPEN_DELETE</tt> flag is set.
138 * @throws IllegalArgumentException if the <tt>mode</tt> argument is invalid
139 * @see SecurityManager#checkRead(java.lang.String)
140 * @since 1.3
141 */
142 public ZipFile(File file, int mode) throws IOException {
143 this(file, mode, Charset.forName("UTF-8"));
144 }
145
146 /**
147 * Opens a ZIP file for reading given the specified File object.
148 *
149 * <p>The UTF-8 {@link java.nio.charset.Charset charset} is used to
150 * decode the entry names and comments.
151 *
152 * @param file the ZIP file to be opened for reading
153 * @throws ZipException if a ZIP format error has occurred
154 * @throws IOException if an I/O error has occurred
155 */
156 public ZipFile(File file) throws ZipException, IOException {
157 this(file, OPEN_READ);
158 }
159
160 private ZipCoder zc;
161
162 /**
163 * 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.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
|