解决压缩文件中存在中文名称解压错误问题
try {
//知道解压字符集
ZipFile zipFile = new ZipFile(fileZip,Charset.forName("GBK")) ;
ZipInputStream zis = new ZipInputStream ( new FileInputStream (fileZip), Charset.forName("GBK"));
ZipEntry entry = null ;
while ( ( entry = zis.getNextEntry()) != null ){
File outFile = new File (entry.getName()) ;
BufferedInputStream bis = new BufferedInputStream (zipFile.getInputStream ( entry ) ) ;
// 输出文件
BufferedOutputStream bos = new BufferedOutputStream (
new FileOutputStream ( outFile ) ) ;
byte [ ] b = new byte [ 2048 ] ;
while ( true ){
int len = bis.read ( b ) ;
if ( len == - 1 )
break ;
bos.write ( b , 0 , len ) ;
}
bis.close ( ) ;
bos.close ( ) ;
}
zis.close() ;
} catch (Exception e) {
e.printStackTrace();
}