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
  • 相关阅读:
    超级楼梯
    hdu1040
    hdu2033(惭愧)
    hdu2032杨辉三角
    hdu1013Digital Roots
    hdu2031
    Linux信号(signal) 机制分析
    android init重启service(进程)
    [android] init进程 .rc文件中service、action的parsing
    oom_adj
  • 原文地址:https://www.cnblogs.com/s0611163/p/14325465.html
Copyright © 2011-2022 走看看