zoukankan      html  css  js  c++  java
  • 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;
    }

  • 相关阅读:
    A1039 Course List for Student (25 分)
    A1101 Quick Sort (25 分)
    日常笔记6C++标准模板库(STL)用法介绍实例
    A1093 Count PAT's (25 分)
    A1029 Median (25 分)
    A1089 Insert or Merge (25 分)
    A1044 Shopping in Mars (25 分)
    js 验证
    根据string获取对应类型的对应属性
    HTML 只能输入数字
  • 原文地址:https://www.cnblogs.com/sddychj/p/6800489.html
Copyright © 2011-2022 走看看