开发者社区> 问答> 正文

关于java检索zip文件内容报错 报错

"

如下代码

public static void main(String[] args) { // TODO Auto-generated method stub try { readZipFile("E:/download/SEEP設定_K2.zip"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void readZipFile(String file) throws Exception { 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()) { } else { System.err.println("file - " + ze.getName() + " : " + ze.getSize() + " bytes"); long size = ze.getSize(); if (size > 0) { BufferedReader br = new BufferedReader(new InputStreamReader(zf.getInputStream(ze))); String line; while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); } System.out.println(); } } zin.closeEntry(); }

错误信息

java.util.zip.ZipException: invalid CEN header (encrypted entry)
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:215)
    at java.util.zip.ZipFile.<init>(ZipFile.java:145)
    at java.util.zip.ZipFile.<init>(ZipFile.java:116)
    at test.readZipFile(test.java:26)
    at test.main(test.java:18)
"

展开
收起
因为相信,所以看见。 2020-05-27 12:59:54 939 0
1 条回答
写回答
取消 提交回答
  • 阿里,我所有的向往

    这个应该是你maven库里的jar损坏了,国内下载这些库文件容易下载不全,删除重新下载一下应该就可以了。

    2020-05-27 16:23:40
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载