Android InputStream Unzip uncompress(InputStream inputStream)

Here you can find the source of uncompress(InputStream inputStream)

Description

uncompress

License

Open Source License

Declaration

public static String uncompress(InputStream inputStream)
        throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

import java.util.zip.GZIPInputStream;

public class Main {

    public static String uncompress(String str) throws IOException {
        if (str == null || str.length() == 0) {
            return str;
        }//from   ww w .j a  v a2s . com
        ByteArrayInputStream in = new ByteArrayInputStream(
                str.getBytes("UTF-8"));
        return uncompress(in);
    }

    public static String uncompress(InputStream inputStream)
            throws IOException {
        if (inputStream == null) {
            return null;
        }
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        GZIPInputStream gunzip = new GZIPInputStream(inputStream);
        byte[] buffer = new byte[256];
        int n;
        while ((n = gunzip.read(buffer)) >= 0) {
            out.write(buffer, 0, n);
        }
        return out.toString();
    }
}

Related

  1. unpackZip(InputStream zipStream, String unpackPath)
  2. unzip(InputStream fileIn, File dirOut)
  3. decompress(InputStream is, OutputStream os)
  4. decompress(InputStream is, OutputStream os)
  5. decompress(InputStream is, OutputStream os)
  6. unpackZip(Context context, String s, InputStream is)
  7. readEntryAsWhatEverInternal( final ZipEntry entry, final InputStream unzippedInputStream)
  8. getZipFileList(InputStream is)
  9. extZipFile(InputStream is, String extPlace)