如何保存一个ZipInputStream的副本?

java 代码
  1. package ziptest;   
  2.   
  3. import java.io.FileInputStream;   
  4. import java.io.FileNotFoundException;   
  5. import java.io.IOException;   
  6. import java.io.InputStream;   
  7. import java.util.zip.ZipEntry;   
  8. import java.util.zip.ZipInputStream;   
  9.   
  10. /**  
  11.  * @version 2007-10-30  
  12.  * @author: Calvin Lee  
  13.  */  
  14. public class ZipTest {   
  15.     public static void main(String[] args) {   
  16.   
  17.         try {   
  18.             ZipInputStream zin = new ZipInputStream(new FileInputStream(   
  19.                     "d:/websale_rfid.zip"));   
  20.             FileInputStream filein = new FileInputStream("d:/websale_rfid.zip");   
  21.                         ZipInputStream zin2 = new ZipInputStream(zin);   
  22.                
  23.             ZipEntry entry;   
  24.             try {   
  25.                 while ((entry = zin.getNextEntry()) != null) {   
  26.                     System.out.println("++++++++++++++++" + (entry.getName()));   
  27.                     zin.closeEntry();   
  28.                 }  

 

  1.                 //zin2没能够正确形成   
  2.                 while ((entry = zin2.getNextEntry()) != null) {   
  3.                     System.out.println("~~~~~~~~~~~~~~~~~~" + (entry.getName()));   
  4.                     zin2.closeEntry();   
  5.                 }   
  6.   
  7.             } catch (IOException e) {   
  8.                 e.printStackTrace();   
  9.             }   
  10.         } catch (FileNotFoundException e) {   
  11.             e.printStackTrace();   
  12.         }   
  13.   
  14.     }   
  15.   
  16.       

输出为

++++++++++++++++forms.xml
++++++++++++++++gpd.xml
++++++++++++++++processdefinition.xml
++++++++++++++++processimage.jpg

而~~~~并没有输出

ZipInputStream zin2 = new ZipInputStream(zin); 为什么代码中zin2没能正确获得...???

如果我想重新读取一次zip流该怎么实现呢?------------------先不要告诉我根据FileInputStream再生成一次.......

直接根据原来的zip流不可以吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值