解压缩字节zip数据

时间:2012-02-20 11:11:12

标签: android zip unzip

我想解压缩一个zip文件。我把zip数据作为字节。我使用下面的代码解压缩zip文件。但是我可以从zip文件中的文件中读取名称。但输出数据已损坏。我想我正在ZipInputStream中读取整个数据。我怎样才能读取每个文件数据? Plz帮助我 感谢..

ByteArrayInputStream binput = new ByteArrayInputStream(zipeddatainbyte);
    ZipInputStream mzipstream = new ZipInputStream(binput);
    File f2 = new File("/sdcard/Unziped Data/");
    f2.mkdirs();
    ZipEntry entry;
    FileOutputStream out;
    byte[] bout=null;
    try {
        while ((entry = mzipstream.getNextEntry()) != null) {
            System.out.println("entry: " + entry.getName() + ", "
                    + entry.getSize());
            bout=new byte[(int) entry.getSize()];
            mzipstream.read(bout);
            out = new FileOutputStream("/sdcard/Unziped Data/"+entry.getName());
            out.write(bout);
            out.close();



        }
    } catch (IOException e) {

        e.printStackTrace();
    }

0 个答案:

没有答案