我是靠谱客的博主 敏感流沙,这篇文章主要介绍java解压zip异常_zip 文件解压缩问题解决 java.util.zip.ZipException:error in opening zip file | 学步园...,现在分享给大家,希望可以做个参考。

程序一直是运行好的,突然在另一台服务器上部署,发现不能解压文件, java.util.zip.ZipException:error in opening zip file

程序代码如下:

public static void unzip(String sourceZip, String outputPath) throws Exception {

if (sourceZip == null || outputPath == null) {

return;

}

ZipInputStream in = new ZipInputStream(new FileInputStream(sourceZip));

ZipEntry zipEntry = null;

while ((zipEntry = in.getNextEntry()) != null) {

File dir = new File(outputPath);

dir.mkdir();

File fil = new File(dir, zipEntry.getName());

FileOutputStream out = new FileOutputStream(fil);

int m = -1;

byte[] buffer = new byte[bufferSize];

while ((m = in.read(buffer, 0, 100)) != -1) {

out.write(buffer, 0, m);

}

out.close();

}

in.clo

最后

以上就是敏感流沙最近收集整理的关于java解压zip异常_zip 文件解压缩问题解决 java.util.zip.ZipException:error in opening zip file | 学步园...的全部内容,更多相关java解压zip异常_zip内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(128)

评论列表共有 0 条评论

立即
投稿
返回
顶部