2024年4月2日发(作者:)

java解压zip文件(由于zip包使用Winra工具打的包,他的默认编码格式是gbk,

所以在解压zip包中的中文文件明的文件的时候就会出现IllegalArguementException异

常,解决方法就是在ZipInputStream 的 getUTF8String()方法中加上如下代码 String

s=new String(b,off,len,"gbk"); return s;编译后将ZipInputStream 的class文件覆盖

中包中的)

try {

// ZipInputStream zis = new ZipInputStream(new FileInputStream(

// ""));

ZipInputStream zis = new ZipInputStream(new FileInputStream(""));

// ZipFile z=new ZipFile();

ZipEntry ze = null;

while ((ze=tEntry()) != null) {

if (!ctory()) {

n(e());

// File child = new File(e());

String filename=e();

int at=dexOf("/");

n(at);

if(at!=-1)

{

String path=ing(0, at);

File pa=new File(path);

();

FileOutputStream outputStream

FileOutputStream(pa+ing(at));

new =

byte[] buffer = new byte[1024];

int bytesRead = 0;

while ((bytesRead = (buffer)) > 0) {

(buffer, 0, bytesRead);

}

();

();

}else

{

FileOutputStream outputStream = new FileOutputStream(filename);

byte[] buffer = new byte[1024];

int bytesRead = 0;

while ((bytesRead = (buffer)) > 0) {

(buffer, 0, bytesRead);

}

();

();

}

}

}

();

} catch (Exception e) {

tackTrace();

}