{"id":2124,"date":"2017-08-15T09:37:16","date_gmt":"2017-08-15T01:37:16","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=2124"},"modified":"2026-08-18T12:09:38","modified_gmt":"2026-08-18T04:09:38","slug":"%e6%96%87%e4%bb%b6%e5%8e%8b%e7%bc%a9%e5%92%8c%e8%a7%a3%e5%8e%8b","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=2124","title":{"rendered":"\u6587\u4ef6\u538b\u7f29\u548c\u89e3\u538b"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<p style=\"margin: 1em 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">java.util.zip<\/code> \u5305\u63d0\u4f9b\u4e86\u5bf9\u6587\u4ef6\u538b\u7f29\u548c\u89e3\u538b\u7f29\u7684\u5904\u7406\u7c7b\uff0c\u5b83\u4eec\u7ee7\u627f\u81ea\u5b57\u8282\u6d41 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">OutputStream<\/code> \u548c <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">InputStream<\/code>\u3002<\/p>\n<p style=\"margin: 1em 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">GZIPOutputStream<\/code> \u548c <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">ZipOutputStream<\/code> \u53ef\u5206\u522b\u628a\u6570\u636e\u538b\u6210 GZIP \u548c Zip \u683c\u5f0f\uff1b<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">GZIPInputStream<\/code> \u548c <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">ZipInputStream<\/code> \u518d\u628a\u538b\u7f29\u6570\u636e\u8fd8\u539f\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e00\u3001\u538b\u7f29\u6b65\u9aa4<\/h2>\n<p style=\"margin: 1em 0px;\">\u628a\u6587\u4ef6\u5199\u5165\u538b\u7f29\u6587\u4ef6\uff0c\u4e00\u822c\u6309\u4e0b\u9762\u8d70\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">1.\u751f\u6210\u548c\u6240\u8981\u751f\u6210\u7684\u538b\u7f29\u6587\u4ef6\u76f8\u5173\u8054\u7684\u538b\u7f29\u7c7b\u5bf9\u8c61\u3002\n  ( ZipOutputStream )\n2.\u538b\u7f29\u6587\u4ef6\u901a\u5e38\u4e0d\u53ea\u5305\u542b\u4e00\u4e2a\u6587\u4ef6\uff0c\u5c06\u6bcf\u4e2a\u8981\u52a0\u5165\u7684\u6587\u4ef6\u79f0\u4e3a\u4e00\u4e2a\u538b\u7f29\u5165\u53e3\uff0c\u4f7f\u7528ZipEntry(String FileName)\u751f\u6210\u538b\u7f29\u5165\u53e3\u5bf9\u8c61\u3002\n  (new ZipEntry(args[i]))\n3.\u4f7f\u7528 putNextEntry(ZipEntry entry)\u5c06\u538b\u7f29\u5165\u53e3\u52a0\u5165\u538b\u7f29\u6587\u4ef6\u3002\n4.\u5c06\u6587\u4ef6\u5185\u5bb9\u5199\u5165\u6b64\u538b\u7f29\u6587\u4ef6\u3002\n5.\u4f7f\u7528 closeEntry()\u7ed3\u675f\u76ee\u524d\u7684\u538b\u7f29\u5165\u53e3\uff0c\u7ee7\u7eed\u4e0b\u4e00\u4e2a\u538b\u7f29\u5165\u53e3\u3002<\/code><\/pre>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e8c\u3001\u89e3\u538b\u6b65\u9aa4<\/h2>\n<p style=\"margin: 1em 0px;\">\u4ece\u538b\u7f29\u6587\u4ef6\u4e2d\u8bfb\u51fa\uff0c\u4e00\u822c\u662f\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">1.\u751f\u6210\u548c\u6240\u8981\u8bfb\u5165\u7684\u538b\u7f29\u6587\u4ef6\u76f8\u5173\u8054\u7684\u538b\u7f29\u7c7b\u5bf9\u8c61\u3002\n2.\u5229\u7528 getNextEntry()\u5f97\u5230\u4e0b\u4e00\u4e2a\u538b\u7f29\u5165\u53e3\u3002<\/code><\/pre>\n<table style=\"display: table; text-align: left; overflow: auto; border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; overflow-wrap: break-word; word-break: break-all;\" width=\"800\">\n<thead>\n<tr>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u65b9\u5411<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u5173\u952e\u7c7b<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u5165\u53e3\u64cd\u4f5c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u538b\u7f29<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">ZipOutputStream \/ GZIPOutputStream<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">putNextEntry \u2192 write \u2192 closeEntry<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u89e3\u538b<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">ZipInputStream \/ GZIPInputStream<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">getNextEntry \u5faa\u73af\u8bfb\u51fa<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e09\u3001\u4f8b 10-13<\/h2>\n<p style=\"margin: 1em 0px;\">\u8f93\u5165\u82e5\u5e72\u6587\u4ef6\u540d\uff0c\u5c06\u6240\u6709\u6587\u4ef6\u538b\u7f29\u4e3a <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">ep10_13.zip<\/code>\uff0c\u518d\u4ece\u538b\u7f29\u6587\u4ef6\u4e2d\u89e3\u538b\u5e76\u663e\u793a\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">import java.io.*;\nimport java.util.*;\nimport java.util.zip.*;\nclass ep10_13{\n    public static void main(String args[]) throws IOException{\n        FileOutputStream a=new FileOutputStream(\"E\uff1a\\\\ep10_13.zip\");\n        \/\/\u5904\u7406\u538b\u7f29\u6587\u4ef6\n        ZipOutputStream out=new ZipOutputStream(new BufferedOutputStream(a));\n        for(int i=0;i&lt;args.length;i++){  \/\/\u5bf9\u547d\u4ee4\u884c\u8f93\u5165\u7684\u6bcf\u4e2a\u6587\u4ef6\u8fdb\u884c\u5904\u7406\n            System.out.println(\"Writing file\"+args[i]);\n            BufferedInputStream in=new BufferedInputStream(new FileInputStream(args[i]));\n            out.putNextEntry(new ZipEntry(args[i]));  \/\/\u8bbe\u7f6e ZipEntry \u5bf9\u8c61\n            int b;\n            while((b=in.read())!=-1)\n                out.write(b);  \/\/\u4ece\u6e90\u6587\u4ef6\u8bfb\u51fa\uff0c\u5f80\u538b\u7f29\u6587\u4ef6\u4e2d\u5199\u5165\n            in.close();\n        }\n        out.close();\n        \/\/\u89e3\u538b\u7f29\u6587\u4ef6\u5e76\u663e\u793a\n        System.out.println(\"Reading file\");\n        FileInputStream d=new FileInputStream(\"F:\\\\ep10_13.zip\");\n        ZipInputStream  inout=new  ZipInputStream(new BufferedInputStream(d));\n        ZipEntry z;\n\n        while((z=inout.getNextEntry())!=null){  \/\/\u83b7\u5f97\u5165\u53e3\n            System.out.println(\"Reading file\"+z.getName());  \/\/\u663e\u793a\u6587\u4ef6\u521d\u59cb\u540d\n            int x;\n            while((x=inout.read())!=-1)\n                System.out.write(x);\n            System.out.println();\n        }\n        inout.close();\n    }\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4f8b 10-13 \u8fd0\u884c\u540e\uff0c\u4f1a\u5728\u7a0b\u5e8f\u76ee\u5f55\u5efa\u7acb\u4e00\u4e2a <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">ep10_13.zip<\/code>\uff0c\u7528 WinRAR \u7b49\u89e3\u538b\u7f29\u8f6f\u4ef6\u53ef\u4ee5\u6253\u5f00\u3002<\/p>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\">\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1aZip \u538b\u7f29\u9760 ZipOutputStream + ZipEntry \u9010\u4e2a\u5199\u5165\u5165\u53e3\uff0c\u89e3\u538b\u9760 ZipInputStream \u5faa\u73af getNextEntry \u8bfb\u51fa\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>java.util.zip \u5305\u63d0\u4f9b\u4e86\u5bf9\u6587\u4ef6\u538b\u7f29\u548c\u89e3\u538b\u7f29\u7684\u5904\u7406\u7c7b\uff0c\u5b83\u4eec\u7ee7\u627f\u81ea\u5b57\u8282\u6d41 OutputStream \u548c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[22],"tags":[41],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2124"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2124"}],"version-history":[{"count":2,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2124\/revisions"}],"predecessor-version":[{"id":2126,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2124\/revisions\/2126"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}