android 解析zip文件

阅读更多
private void readZipFile(String file){
        ZipFile zf = null;
        try {
            zf = new ZipFile(file);
            InputStream in = new BufferedInputStream(new FileInputStream(file));
            ZipInputStream zin = new ZipInputStream(in);
            ZipEntry ze;
            while ((ze = zin.getNextEntry()) != null) {
                if (ze.isDirectory()) {
                    //Do nothing
                } else {
                    if (ze.getName().contains("payload_properties.txt")) {
                        BufferedReader br = new BufferedReader(
                        new InputStreamReader(zf.getInputStream(ze)));
                        String line;
                        while ((line = br.readLine()) != null) {
                            headerKeyValuePairs[i] = line;
                            i++;
                        }
                        br.close();
                    }
                    if (ze.getName().contains("metadata")) {
                        BufferedReader br = new BufferedReader(
                        new InputStreamReader(zf.getInputStream(ze)));
                        String line;
                        while ((line = br.readLine()) != null) {
                            updateTemp1[j] = line;
                            j++;
                        }
                        br.close();
                    }
                }
            }
            zin.closeEntry();
            readSize();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

 

你可能感兴趣的:(android 解析zip文件)