• java 解压缩 中文名称问题


    public List<String> unZip(String pathString, String zipPathString) {
    long startTime = System.currentTimeMillis();
    List<String> list = new ArrayList<>();
    try {
    Charset charset = Charset.forName("GBK");
    ZipInputStream Zin = new ZipInputStream(new FileInputStream(
    zipPathString), charset);// 输入源zip路径
    BufferedInputStream Bin = new BufferedInputStream(Zin);
    String Parent = pathString; // 输出路径(文件夹目录)
    File Fout = null;
    ZipEntry entry;
    // List<ImgItem> list = new ArrayList<ImgItem>();
    try {
    while ((entry = Zin.getNextEntry()) != null
    && !entry.isDirectory()) {
    String filenameString = entry.getName();
    list.add(filenameString);
    Fout = new File(Parent, filenameString);
    if (!Fout.exists()) {
    (new File(Fout.getParent())).mkdirs();
    }
    FileOutputStream out = new FileOutputStream(Fout);
    BufferedOutputStream Bout = new BufferedOutputStream(out);
    int b;
    while ((b = Bin.read()) != -1) {
    Bout.write(b);
    }
    Bout.close();
    out.close();
    System.out.println(Fout + "解压成功");
    }
    Bin.close();
    Zin.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    }
    long endTime = System.currentTimeMillis();
    System.out.println("耗费时间: " + (endTime - startTime) + " ms");
    return list;
    }

  • 相关阅读:
    Python标准库之csv(1)
    python3:csv的读写
    Python os模块方法
    Python闭包
    Python修饰器
    Python生成器
    Python迭代器
    Python文件对象方法
    Justep X5 Studio,业界公认第一的快速开发平台
    马云:早九晚五的工作方式在2013-2015年就是慢性自杀
  • 原文地址:https://www.cnblogs.com/sddychj/p/6800489.html
Copyright © 2020-2023  润新知