我的文件结构是这样的,在一个压缩包里面是10个压缩文件,每个压缩文件解出来就是一个txt文件。我怎样可以将这个大的压缩包解压出来放在D:\1这个文件夹,1这个文件夹里面全部是未解压的10个压缩包?或者能不能一次解压,将所有的txt文档都解出来,放在D:\1文件夹里面?

解决方案 »

  1.   

    一个循环就行吧ZipInputStream zip = new ZipInputStream(new FileInputStream("D:\\Temp\\1\\1.zip"));
    ZipEntry entry = zip.getNextEntry();
    while(entry != null) {
    ZipInputStream txtZip = new ZipInputStream(zip);
    ZipEntry txtEntry = txtZip.getNextEntry();

    FileOutputStream fos = new FileOutputStream("D:\\Temp\\1\\" + txtEntry.getName());
    byte[] buff = new byte[1024];
    int readed;
    while((readed = txtZip.read(buff)) > 0)
    fos.write(buff, 0, readed);
    fos.close();

    zip.closeEntry();
    entry = zip.getNextEntry();
    }
      

  2.   

    java调用winrar.exe解压第一个包就行了啊,.......
      

  3.   

    用FileOutputStream的时候遇到问题,解出来的文档都是空的·~~~我最后在网上找了段程序可行~~