zoukankan      html  css  js  c++  java
  • Java ZIP文件解压

    Java ZIP文件解压 备忘笔记

    代码:

        private byte[] unZip(byte[] data) {
            byte[] bArr = null;
            try {
                ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(data);
                ZipInputStream zipInputStream = new ZipInputStream(byteArrayInputStream);
                ZipEntry zipEntry = null;
    
                while ((zipEntry = zipInputStream.getNextEntry()) != null) {
                    if (zipEntry.isDirectory()) continue;
    
                    byte[] buffer = new byte[1024];
                    int num = -1;
                    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    
                    while ((num = zipInputStream.read(buffer, 0, buffer.length)) != -1) {
                        outputStream.write(buffer, 0, num);
                    }
    
                    bArr = outputStream.toByteArray();
                    outputStream.flush();
                    outputStream.close();
    
                    if (zipEntry.getName().toUpperCase().equals("GAB_ZIP_INDEX.XML")) { //索引文件
                        String xmlStr = new String(bArr, "utf-8");
                        indexXml = getIndexXml(xmlStr);
                    }
    
                    if (zipEntry.getName().toUpperCase().indexOf(".BCP") > 0) { //bcp数据文件
                        String bcpStr = new String(bArr, "utf-8");
                        bcpContent.put(zipEntry.getName(), bcpStr);
                    }
                }
    
                zipInputStream.close();
                byteArrayInputStream.close();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            return bArr;
        }
    View Code
  • 相关阅读:
    java中字符串类型的比较
    iOS 检测是否插入耳机
    Model-View-Controller (The iPhone Developer's Cookbook)
    Spring Animation
    CoreImage 自动增强滤镜 以及 系统滤镜查询
    UIView Animation
    CoreImage 查询系统滤镜
    CoreImage 的人脸检测
    Smarty 模板操作
    smarty转载(1)
  • 原文地址:https://www.cnblogs.com/s0611163/p/14325465.html
Copyright © 2011-2022 走看看