Java解压zip失败
publicclassCopyOfMyzipDecompressing{publicstaticvoidmain(String[]args){longstartTime=...
public class CopyOfMyzipDecompressing {
public static void main(String[] args) {
long startTime=System.currentTimeMillis();
System.out.println(startTime);
try {
System.out.println("111111111111");
ZipInputStream Zin=new ZipInputStream(new FileInputStream(
"C:/Users/Administrator/Desktop/zm.zip"));//输入源zip路径
System.out.println("123321"+Zin);
BufferedInputStream Bin=new BufferedInputStream(Zin);
String Parent="C:\\Users\\Administrator\\Desktop\\"; //输出路径(文件夹目录)
System.out.println(Bin);
File Fout=null;
ZipEntry entry;
System.out.println("6666666666666");
try {
while((entry = Zin.getNextEntry())!=null && !entry.isDirectory()){
Fout=new File(Parent,entry.getName());
System.out.println("77777777777777777");
if(!Fout.exists()){
(new File(Fout.getParent())).mkdirs();
}
System.out.println("8888888888888888888");
FileOutputStream out=new FileOutputStream(Fout);
BufferedOutputStream Bout=new BufferedOutputStream(out);
int b;
while((b=Bin.read())!=-1){
Bout.write(b);
}
Bout.close();
out.close();
System.out.println(Fout+"解压成功");
}
System.out.println("999999999999999");
Bin.close();
Zin.close();
} catch (IOException e) {
System.out.println("错误显示1"+e.getMessage());
}
System.out.println("10101010101");
} catch (FileNotFoundException e) {
System.out.println("错误显示2"+e.getMessage());
}
long endTime=System.currentTimeMillis();
System.out.println("耗费时间: "+(endTime-startTime)+" ms");
}
}
下面是错误提示
123321java.util.zip.ZipInputStream@c17164
java.io.BufferedInputStream@1fb8ee3
6666666666666
Exception in thread "main" java.lang.IllegalArgumentException
at java.util.zip.ZipInputStream.getUTF8String(Unknown Source)
at java.util.zip.ZipInputStream.readLOC(Unknown Source)
at java.util.zip.ZipInputStream.getNextEntry(Unknown Source)
at com.mbl.util.CopyOfMyzipDecompressing.main(CopyOfMyzipDecompressing.java:33)
//这是错误提示 展开
public static void main(String[] args) {
long startTime=System.currentTimeMillis();
System.out.println(startTime);
try {
System.out.println("111111111111");
ZipInputStream Zin=new ZipInputStream(new FileInputStream(
"C:/Users/Administrator/Desktop/zm.zip"));//输入源zip路径
System.out.println("123321"+Zin);
BufferedInputStream Bin=new BufferedInputStream(Zin);
String Parent="C:\\Users\\Administrator\\Desktop\\"; //输出路径(文件夹目录)
System.out.println(Bin);
File Fout=null;
ZipEntry entry;
System.out.println("6666666666666");
try {
while((entry = Zin.getNextEntry())!=null && !entry.isDirectory()){
Fout=new File(Parent,entry.getName());
System.out.println("77777777777777777");
if(!Fout.exists()){
(new File(Fout.getParent())).mkdirs();
}
System.out.println("8888888888888888888");
FileOutputStream out=new FileOutputStream(Fout);
BufferedOutputStream Bout=new BufferedOutputStream(out);
int b;
while((b=Bin.read())!=-1){
Bout.write(b);
}
Bout.close();
out.close();
System.out.println(Fout+"解压成功");
}
System.out.println("999999999999999");
Bin.close();
Zin.close();
} catch (IOException e) {
System.out.println("错误显示1"+e.getMessage());
}
System.out.println("10101010101");
} catch (FileNotFoundException e) {
System.out.println("错误显示2"+e.getMessage());
}
long endTime=System.currentTimeMillis();
System.out.println("耗费时间: "+(endTime-startTime)+" ms");
}
}
下面是错误提示
123321java.util.zip.ZipInputStream@c17164
java.io.BufferedInputStream@1fb8ee3
6666666666666
Exception in thread "main" java.lang.IllegalArgumentException
at java.util.zip.ZipInputStream.getUTF8String(Unknown Source)
at java.util.zip.ZipInputStream.readLOC(Unknown Source)
at java.util.zip.ZipInputStream.getNextEntry(Unknown Source)
at com.mbl.util.CopyOfMyzipDecompressing.main(CopyOfMyzipDecompressing.java:33)
//这是错误提示 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |