如何解决java.util.zip.crc32ZipException

温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
阅读(1563)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'Java操作Jar、Zip',
blogAbstract:'Java操作Jar:package com.xiao.import java.io.Fimport java.io.FileInputSimport java.io.FileOutputSimport java.io.IOEimport java.io.InputSimport java.util.Eimport java.util.jar.JarE',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:8,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'0',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}Java 解压缩zip文件 - 每天叫醒我的不是闹钟,其实,是梦想! - ITeye技术网站
博客分类:
不借助于其他的第三方组件,直接使用java提供的方法通过IO流操作zip文件。
package com.
import java.io.F
import java.io.BufferedOutputS
import java.io.BufferedInputS
import java.io.FileOutputS
import java.io.FileInputS
import java.util.zip.ZipE
import java.util.zip.ZipInputS
import java.util.zip.ZipOutputS
* 该类实现文件夹压缩成zip文件和zip文件解压
* @author Administrator
public class Zip{
private ZipInputStream
private ZipOutputStream zipO
private ZipEntry
private static int
//size of bytes
private byte[]
private int
public Zip(){
this(512);
public Zip(int bufSize){
this.bufSize = bufS
this.buf = new byte[this.bufSize];
//压缩文件夹内的文件
public void doZip(String zipDirectory){//zipDirectoryPath:需要压缩的文件夹名
zipDir = new File(zipDirectory);
String zipFileName = zipDirectory + ".zip";//压缩后生成的zip文件名
this.zipOut = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFileName)));
handleDir(zipDir , this.zipOut);
this.zipOut.close();
}catch(Exception ioe){
ioe.printStackTrace();
//由doZip调用,递归完成目录文件读取
private void handleDir(File dir , ZipOutputStream zipOut)throws Exception{
FileInputStream fileIn;
files = dir.listFiles();
if(files.length == 0){//如果目录为空,则单独创建之.
//ZipEntry的isDirectory()方法中,目录以"/"结尾.
this.zipOut.putNextEntry(new ZipEntry(dir.toString() + "/"));
this.zipOut.closeEntry();
else{//如果目录不为空,则分别处理目录和文件.
for(File fileName : files){
if(fileName.isDirectory()){
handleDir(fileName , this.zipOut);
fileIn = new FileInputStream(fileName);
String name=dir.getName();
//生成的压缩包存放在原目录下
this.zipOut.putNextEntry(new ZipEntry(name+"/"+fileName.getName().toString()));
//此方法存放在该项目目录下
//this.zipOut.putNextEntry(new ZipEntry(fileName.toString()));
while((this.readedBytes=fileIn.read(this.buf))&0){
this.zipOut.write(this.buf , 0 , this.readedBytes);
this.zipOut.closeEntry();
//解压指定zip文件
public void unZip(String unZipfileName){//unZipfileName需要解压的zip文件名
FileOutputStream fileO
String f=unZipfileName.substring(0, unZipfileName.length()-4);
File ff=new File(f);
this.zipIn = new ZipInputStream (new
BufferedInputStream(new FileInputStream(unZipfileName)));
while((this.zipEntry = this.zipIn.getNextEntry()) != null){
file = new File(this.zipEntry.getName());
if(this.zipEntry.isDirectory()){
file.mkdirs();
//如果指定文件的目录不存在,则创建之.
File parent = file.getParentFile();
if(!parent.exists()){
parent.mkdirs();
if(!ff.exists()){
ff.mkdir();
fileOut = new FileOutputStream(f+"/"+file.getName());
//fileOut = new FileOutputStream(file); 此方法存放到该项目目录下
while(( this.readedBytes = this.zipIn.read(this.buf) ) & 0){
fileOut.write(this.buf , 0 , this.readedBytes );
fileOut.close();
this.zipIn.closeEntry();
}catch(Exception ioe){
ioe.printStackTrace();
//设置缓冲区大小
public void setBufSize(int bufSize){
this.bufSize = bufS
//测试Zip类
public static void main(String[] args)throws Exception{
Zip zip=new Zip();
zip.doZip("c:\\test");
zip.unZip("c:\\test.zip");
浏览: 1207152 次
来自: 深圳
怎么没哟了,继续赛
100行会报空指针
问题确实解决,好使!5820人阅读
J2EE(22)
& 程序一直是运行好的,突然在另一台服务器上部署,发现不能解压文件,&java.util.zip.ZipException:error in opening zip file
& 程序代码如下:
&& public static void unzip(String sourceZip, String outputPath) throws Exception {
if (sourceZip == null || outputPath == null) {
ZipInputStream in = new ZipInputStream(new FileInputStream(sourceZip));
ZipEntry zipEntry =
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.&init&(ZipFile.java:127)
at java.util.jar.JarFile.&init&(JarFile.java:135)
at java.util.jar.JarFile.&init&(JarFile.java:72)
at sun.net.www.protocol.jar.URLJarFile.&init&(URLJarFile.java:72)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:48)
at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:70)
因为是测试环境是可以跑起来,那说明是环境出了问题,后面经过排查,发现编译环境的JDK与生产环境的JDK版本不同。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:151208次
积分:2488
积分:2488
排名:第12895名
原创:99篇
转载:22篇
评论:43条
(1)(1)(1)(2)(3)(5)(5)(2)(1)(8)(3)(1)(1)(1)(4)(6)(1)(5)(20)(5)(1)(8)(6)(2)(19)(5)(4)This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript supportjava.util.zip.ZipException: invalid entry size - 九霄 - ITeye技术网站
博客分类:
遇到一个错误
java.util.zip.ZipException: invalid entry size
使用jetty插件启动 的时候报错。
还没找到原因,怀疑是包冲突引起的。
原项目jetty启动正常,但是引入了poi3.8的 两个jar
&dependency&
&groupId&org.apache.poi&/groupId&
&artifactId&poi&/artifactId&
&version&3.8&/version&
&/dependency&
&dependency&
&groupId&org.apache.poi&/groupId&
&artifactId&poi-ooxml&/artifactId&
&version&3.8&/version&
&/dependency&
就开始报错了。
改换 tomcat 插件启动 ,成功。
以下是tomcat 启动的 配置方式
两种任选其一即可:
&!-- cargo:tomcat 单独文件夹中启动 --&
&groupId&org.codehaus.cargo&/groupId&
&artifactId&cargo-maven2-plugin&/artifactId&
&version&1.2.4&/version&
&configuration&
&!-- 配置Tomcat在本地的路径 --&
&container&
&containerId&tomcat6x&/containerId&&!-- 版本号 不可变 --&
&home&E:\tomcat6&/home&&!-- tomcat路径 --&
&/container&
&!-- 配置容器信息 --&
&configuration&
&!-- statndalone表示独立运行,此时会在特定的目录加载一个相应的web项目, 不会加载tomcat中原有的项目 --&
&type&standalone&/type&&!-- 发布到一个独立的文件夹中 --&
&!-- 希望加载路径的目录 --&
&home&D:/tomcat6&/home&
&!-- properties中可以设置相应的端口的配置 --&
&properties&
&!-- 端口号设置9999为 --&
&cargo.servlet.port&9999&/cargo.servlet.port&
&/properties&
&/configuration&
&/configuration&
&!-- cargo tomcat 默认tomcat中启动 --&
&!-- &plugin&
&groupId&org.codehaus.cargo&/groupId&
&artifactId&cargo-maven2-plugin&/artifactId&
&version&1.2.4&/version&
基于existing的方式,会把项目发布到系统的Tomcat中的webapps中
&configuration&
&container&
&containerId&tomcat6x&/containerId&
&home&E:\tomcat6&/home&
&/container&
&configuration&home设置为系统的tomcat目录
&type&existing&/type&
&home&E:\tomcat6&/home&
&/configuration&
&/configuration&
&/plugin& --&
qiyang199132
浏览: 43370 次
来自: 武汉
这个jar包没找到下载的地方啊。

我要回帖

更多关于 java.util.zip jar 的文章

 

随机推荐