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;
    }

  • 相关阅读:
    hdu--2852--树状数组
    hdu--2848--未解决
    二进制与十进制之间蛮好的转换方式
    hdu--2846--字典树<怪我思维不够跳跃>
    hdu--2845--dp
    hdu--2844--多重背包
    hdu--1789--贪心||优先队列
    hdu--1978--记忆化深度搜索||递推
    hdu--2830--任意交换列的矩阵
    hdu--1506--矩阵求和<stack>
  • 原文地址:https://www.cnblogs.com/sddychj/p/6800489.html
Copyright © 2011-2022 走看看