今天弄了一下午解压的问题,需求嘛,把自己踩过的坑记录下来,也为了跟我一样的新人少坑的路。
怎么那么多的屁话,上代码啊!
上解压的代码:
//第一个参数就是需要解压的文件,第二个就是解压的目录
public static boolean upZipFileDir(File zipFile, String folderPath) {
ZipFile zfile= null;
try {
//转码为GBK格式,支持中文
zfile = new ZipFile(zipFile,"GBK");
} catch (IOException e) {
e.printStackTrace();
return false;
}
Enumeration zList=zfile.getEntries();
ZipEntry ze=null;
byte[] buf=new byte[1024];
while(zList.hasMoreElements()){
ze=(ZipEntry)zList.nextElement();
//列举的压缩文件里面的各个文件,判断是否为目录
if(ze.isDirectory()){
String dirstr = folderPath + ze.getName();
dirstr.trim();
File f=new File(dirstr);
f.mkdir();
continue;</