java zip解压压缩碰到坑
String dzFile = jsonObject.getString("dzFile");
try {
File zipFileName = new File("D://" + jsonObject.getString("fileName"));
BASE64Decoder decoder = new BASE64Decoder();
byte[] bytes = decoder.decodeBuffer(dzFile);
FileOutputStream fos = new FileOutputStream(zipFileName);
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ZipOutputStream zipOut = new ZipOutputStream(fos,Charset.forName("GBK"));
String fileName = jsonObject.getString("fileName");
String substring = fileName.substring(0, fileName.indexOf("."));
zipOut.putNextEntry(new ZipEntry(substring+".csv"));
int temp = 0;
while ((temp = bais.read())!=-1){
zipOut.write(temp);
}
zipOut.finish();
zipOut.closeEntry();
zipOut.close();
bais.close();
fos.close();
}catch (Exception e){
e.printStackTrace();
}
大婶门,我碰到困难了,压缩包的文件打不开