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.OutputStream;
29 import java.io.IOException;
30 import java.nio.charset.Charset;
31 import java.nio.charset.StandardCharsets;
32 import java.util.Vector;
33 import java.util.HashSet;
34 import static java.util.zip.ZipConstants64.*;
35 import static java.util.zip.ZipUtils.*;
36
37 /**
38 * This class implements an output stream filter for writing files in the
39 * ZIP file format. Includes support for both compressed and uncompressed
40 * entries.
41 *
42 * @author David Connelly
43 */
44 public
45 class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
46
47 /**
48 * Whether to use ZIP64 for zip files with more than 64k entries.
49 * Until ZIP64 support in zip implementations is ubiquitous, this
50 * system property allows the creation of zip files which can be
51 * read by legacy zip implementations which tolerate "incorrect"
52 * total entry count fields, such as the ones in jdk6, and even
53 * some in jdk7.
54 */
55 private static final boolean inhibitZip64 =
56 Boolean.parseBoolean(
57 java.security.AccessController.doPrivileged(
58 new sun.security.action.GetPropertyAction(
59 "jdk.util.zip.inhibitZip64", "false")));
60
61 private static class XEntry {
62 final ZipEntry entry;
63 final long offset;
64 public XEntry(ZipEntry entry, long offset) {
65 this.entry = entry;
66 this.offset = offset;
67 }
68 }
69
70 private XEntry current;
71 private Vector<XEntry> xentries = new Vector<>();
72 private HashSet<String> names = new HashSet<>();
73 private CRC32 crc = new CRC32();
74 private long written = 0;
75 private long locoff = 0;
76 private byte[] comment;
77 private int method = DEFLATED;
78 private boolean finished;
79
|
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.OutputStream;
29 import java.io.IOException;
30 import java.nio.charset.Charset;
31 import java.nio.charset.StandardCharsets;
32 import java.util.Vector;
33 import java.util.HashSet;
34 import static java.util.zip.ZipConstants64.*;
35 import static java.util.zip.ZipUtils.*;
36 import sun.security.action.GetPropertyAction;
37
38 /**
39 * This class implements an output stream filter for writing files in the
40 * ZIP file format. Includes support for both compressed and uncompressed
41 * entries.
42 *
43 * @author David Connelly
44 */
45 public
46 class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
47
48 /**
49 * Whether to use ZIP64 for zip files with more than 64k entries.
50 * Until ZIP64 support in zip implementations is ubiquitous, this
51 * system property allows the creation of zip files which can be
52 * read by legacy zip implementations which tolerate "incorrect"
53 * total entry count fields, such as the ones in jdk6, and even
54 * some in jdk7.
55 */
56 private static final boolean inhibitZip64 =
57 Boolean.parseBoolean(
58 GetPropertyAction.getProperty("jdk.util.zip.inhibitZip64"));
59
60 private static class XEntry {
61 final ZipEntry entry;
62 final long offset;
63 public XEntry(ZipEntry entry, long offset) {
64 this.entry = entry;
65 this.offset = offset;
66 }
67 }
68
69 private XEntry current;
70 private Vector<XEntry> xentries = new Vector<>();
71 private HashSet<String> names = new HashSet<>();
72 private CRC32 crc = new CRC32();
73 private long written = 0;
74 private long locoff = 0;
75 private byte[] comment;
76 private int method = DEFLATED;
77 private boolean finished;
78
|