zoukankan      html  css  js  c++  java
  • zip文件内存中解压读取

    // 构造zip输入流
    ZipInputStream zip = new ZipInputStream(fis,Charset.forName("gbk"));
    byte[] tmpByte = null;
    ZipEntry tmpEntity = null;
    while ( (tmpEntity = zip.getNextEntry()) != null) {
    byte[] buf = new byte[1024];
    int num = -1;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    logger.info("####file_name:"+tmpEntity.getName());
    while ((num = zip.read(buf, 0, buf.length)) != -1) {
    baos.write(buf, 0, num);
    }
    tmpByte = baos.toByteArray();
    baos.flush();
    baos.close();
    // 处理转换文件
    handelCheckFile(tmpEntity.getName(),tmpByte);
    }
    zip.close();
    fis.close();

    ===============================================================
    private void handelCheckFile(String fileName ,byte[] tmpByte) {
    InputStream inputStream = new ByteArrayInputStream(tmpByte);
    BufferedReader br = new BufferedReader(new InputStreamReader(inputStream,Charset.forName("gbk")));
    String line;
    int num = 0;
    // 循环解析文件
    try {
    logger.info("##下载文件名称fileName:"+fileName);
    while ((line = br.readLine()) != null) {
    logger.info(line);
    }
    } catch (IOException e) {
    e.printStackTrace();
    }
    }

  • 相关阅读:
    ZoomBar 设计
    旋转toast 自定义toast方向,支持多个方向的显示,自定义View
    NA
    ISCSI共享
    DFS序
    矩阵快速幂
    SOJ4389 川大贴吧水王 队列
    ST表学习总结
    HDU 5724 Chess(SG函数)
    2017 计蒜之道 初赛 第一场 A、B题
  • 原文地址:https://www.cnblogs.com/sagech/p/8491752.html
Copyright © 2011-2022 走看看