zip文件解压
zIP文件解压可以用Java自带的解压工具ZipInputStream类。
public static File unZipFile() throws Exception {
FileInputStream fileStream = new FileInputStream ();
ZipInoutStream in = new ZipInputStream(fileStream,Charset.forName("UTF-8"));
ZipEntry zipEntry;
File txtFile = null;
int bufSize = 2048;
byte[] buf = new byte[bufSize];
OutputStream out = null;
try {
while ((zipEntry = in.getNextEntry()) != null) {
File path = new File("D:/");
if (!path.exists()){
path.mkdirs();
}
txtFile = new File("D:/" + zipEntry.getName());
out = new FileOutputStream(txtFile);
int len = 0;
while((len = in.read(buf,0,bufSize)) != -1) {
out.write(buf,0,len);
}
in.closeEntry();
}
}
catch (IOException e) {
e.printStackTrace();
}
finally {
try {
in.close();
}
catch(Exception e) {
e.printStackTrace();
}
try {
out.close();
}
catch(Exception e) {
e.printStackTrace();
}
}
return txtFile;
}

浙公网安备 33010602011771号