Android Zip Unzip File decompress(String paramString)

Here you can find the source of decompress(String paramString)

Description

decompress

Declaration

public static String decompress(String paramString) throws Exception 

Method Source Code

//package com.java2s;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.zip.GZIPInputStream;

public class Main {
    public static String decompress(String paramString) throws Exception {
        return new String(decompress(paramString.getBytes("utf-8")),
                "utf-8");
    }// ww w.  java 2 s  .  c o m

    public static byte[] decompress(byte[] paramArrayOfByte)
            throws Exception {
        ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(
                paramArrayOfByte);
        GZIPInputStream localGZIPInputStream = new GZIPInputStream(
                localByteArrayInputStream);
        ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
        byte[] arrayOfByte = new byte[1024];
        for (;;) {
            int i = localGZIPInputStream.read(arrayOfByte, 0, 1024);
            if (i == -1) {
                localByteArrayInputStream.close();
                localByteArrayOutputStream.flush();
                localByteArrayOutputStream.close();
                localGZIPInputStream.close();
                return localByteArrayOutputStream.toByteArray();
            }
            localByteArrayOutputStream.write(arrayOfByte, 0, i);
        }
    }
}

Related

  1. zipFileAtPath(File sourceFile, String toLocation)
  2. decompress(File file)
  3. decompress(File file)
  4. decompress(File file, boolean delete)
  5. decompress(File file, boolean delete)
  6. decompress(String path)
  7. decompress(String path)
  8. decompress(String path, boolean delete)
  9. decompress(String path, boolean delete)