<script type="text/javascript"> google_ad_client = "pub-8800625213955058"; /* 336x280, 创建于 07-11-21 */ google_ad_slot = "0989131976"; google_ad_width = 336; google_ad_height = 280; // </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> 由于网络带宽有限,所以数据文件的压缩有利于数据在Internet上的快速传输,同时也节 省服务器的外存空间。 Java 1.1实现了I/O数据流与网络数据流的单一接口,因此数据的压缩、网络传输和解 压缩的实现比较容易,下面介绍利用ZipEntry、ZipInputStream和ZipOutputStream三个Java 类实现zip数据压缩方式的编程方法。 zip压缩文件结构:一个zip文件由多个entry组成,每个entry有一个唯一的名称,entry的 数据项存储压缩数据。 与zip文件有关的几个Java类 ·类ZipEntry public ZipEntry(String name); name为指定的数据项名。 ·类ZipOutputStream ZipOutputStream实现了zip压缩文件的写输出流,支持压缩和非压缩entry。下面是它的 几个函数: public ZipOutputStream(OutputStream out); ∥利用输出流out构造一个ZIP输出流。 public void setMethod(int method); ∥设置entry压缩方法,缺省值为DEFLATED。 public void putNextEntry(ZipEntry newe); ∥如果当前的entry存在且处于激活状态时,关闭它,在
利用Java实现zip压缩/解压缩
最新推荐文章于 2022-05-28 12:11:00 发布
本文介绍了如何使用Java中的ZipEntry、ZipOutputStream和ZipInputStream类来实现zip文件的压缩和解压缩。通过示例代码展示了如何创建、读取和写入zip文件,以及设置压缩方法。
摘要由CSDN通过智能技术生成