1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > java解压zip异常_zip 文件解压缩问题解决 java.util.zip.ZipException:error in

java解压zip异常_zip 文件解压缩问题解决 java.util.zip.ZipException:error in

时间:2019-06-11 06:29:49

相关推荐

java解压zip异常_zip 文件解压缩问题解决 java.util.zip.ZipException:error in

程序一直是运行好的,突然在另一台服务器上部署,发现不能解压文件,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.close();

}

Caused by: java.util.zip.ZipException: error in opening zip file

at java.util.zip.ZipFile.open(Native Method)

at java.util.zip.ZipFile.(ZipFile.java:127)

at java.util.jar.JarFile.(JarFile.java:135)

at java.util.jar.JarFile.(JarFile.java:72)

at .www.protocol.jar.URLJarFile.(URLJarFile.java:72)

at .www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:48)

at .www.protocol.jar.JarFileFactory.get(JarFileFactory.java:70)

因为是测试环境是可以跑起来,那说明是环境出了问题,后面经过排查,发现编译环境的JDK与生产环境的JDK版本不同。

java解压zip异常_zip 文件解压缩问题解决 java.util.zip.ZipException:error in opening zip file | 学步园...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。