zoukankan      html  css  js  c++  java
  • windows下解压文件

    /**
    * 解压文件函数
    *
    * @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;
    }

    }
  • 相关阅读:
    接口测试该怎么做
    Mac操作Github实现代码的下载、上传
    Django开发基础--操作数据库
    Django开发基础--创建项目/应用
    Python统计安卓log中Anr、Crash出现的数量
    Mac下PyCharm快捷键大全
    Selenium常用方法及函数、txt参数化
    Appium基于PO模型
    Selenium免登录、等待、unittest、PO模型
    Python接口请求及封装
  • 原文地址:https://www.cnblogs.com/chenweida/p/12119510.html
Copyright © 2011-2022 走看看