不解压压缩包直接解析内部文件(zip)

ZipInputStream.getNextEntry()____________获取压缩文件内下一个文件,如果当前位置是文件夹则从文件夹内获取
ZipFile.getInputStream(ZipEntry) __________获取压缩包内部文件的输入流

示例:

Workbook wb = null;
ZipFile zf = new ZipFile(url);
InputStream in = new BufferedInputStream(new FileInputStream(url));
ZipInputStream zin = new ZipInputStream(in);
ZipEntry ze;
while ((ze = zin.getNextEntry()) != null) {
    String name = ze.getName();
    if (ze.isDirectory()) {
    }else if(name.substring(name.lastIndexOf(".")+1).equals("xlsx")) {
        wb = new XSSFWorkbook(zf.getInputStream(ze));
    }
}

猜你喜欢

转载自blog.csdn.net/qq_39652227/article/details/81706756