android 在不解压压缩文件的情况下,读取压缩文件内容

来源:互联网 发布:个人简介的app源码 编辑:程序博客网 时间:2024/05/16 13:53
/**     * 无需解压直接读取Zip文件和文件内容     *     * @param file     * @throws Exception     */    public static InputStream readZipFile(String file) throws Exception {        InputStream input = null;        ZipFile 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().equals("map.xml")) {                    input = zf.getInputStream(ze);                }            }        }        zin.closeEntry();        return input;    }

原创粉丝点击