chenweida
/**
* 解压文件函数
*
* @param zipPath
* @param descDir
* @return
* @throws IOException
*/
public static List<File> upzipFile(String zipPath, String descDir) throws IOException {
return upzipFile(new File(zipPath), descDir);
}

/**
* 解压文件具体方法
*
* @param zipFile
* @param descDir
* @return
* @throws IOException
*/

@SuppressWarnings("rawtypes")
public static List<File> upzipFile(File zipFile, String descDir) throws IOException {
List<File> _list = new ArrayList<File>();
ZipFile _zipFile = null;
try {
_zipFile = new ZipFile(zipFile, "GBK");
for (Enumeration entries = _zipFile.getEntries(); entries.hasMoreElements(); ) {
ZipEntry entry = (ZipEntry) entries.nextElement();
File _file = new File(descDir + File.separator + entry.getName());
if (entry.isDirectory()) {
_file.mkdirs();
} else {
File _parent = _file.getParentFile();
if (!_parent.exists()) {
_parent.mkdirs();
}
InputStream _in = _zipFile.getInputStream(entry);
OutputStream _out = new FileOutputStream(_file);
int len = 0;
while ((len = _in.read(_byte)) > 0) {
_out.write(_byte, 0, len);
}
_in.close();
_out.flush();
_out.close();
_list.add(_file);

}
}

} catch (IOException e) {

} finally {
_zipFile.close();
}
return _list;
}

/**
* 是否存在文件夹判断
*
* @param file
* @return
*/
public static boolean isFileExists(File file) {

if (file.exists()) {
return true;
} else {
return false;
}

}

分类:

技术点:

相关文章:

  • 2021-07-17
  • 2022-12-23
  • 2021-11-18
  • 2021-07-04
  • 2021-11-23
  • 2021-12-17
  • 2022-02-03
  • 2021-10-10
猜你喜欢
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-28
  • 2022-01-11
  • 2022-01-03
相关资源
相似解决方案