Android Utililty Methods InputStream Unzip

List of utility methods to do InputStream Unzip

Description

The list of methods to do InputStream Unzip are organized into topic(s).

Method

voidunZip(InputStream in, String destDir)
un Zip
final int BUFFER = 1024;
byte data[] = new byte[BUFFER];
ZipInputStream zis = null;
try {
    zis = new ZipInputStream(in);
    ZipEntry entry;
    while ((entry = zis.getNextEntry()) != null) {
        if (entry.isDirectory()) {
...
booleanunZip(InputStream is, String filename, String folderPath)
un Zip
File file = null;
FileOutputStream fos = null;
try {
    file = new File(filename);
    if (!file.exists()) {
        file.createNewFile();
    fos = new FileOutputStream(file);
...
booleanunpackZip(InputStream zipStream, String unpackPath)
Unzip the specified file from a file Be sure to set : Modified from: Source: http://stackoverflow.com/questions/3382996/how-to-unzip-files-programmatically-in-android
InputStream is;
ZipInputStream zis;
try {
    String filename;
    zis = new ZipInputStream(new BufferedInputStream(zipStream));
    ZipEntry ze;
    byte[] buffer = new byte[1024];
    int count;
...
booleanunzip(InputStream fileIn, File dirOut)
This is not tested on hierarchical zip files, currently only used on flat archives
try {
    ZipInputStream zin = new ZipInputStream(fileIn);
    ZipEntry ze = null;
    while ((ze = zin.getNextEntry()) != null) {
        Log.v("Decompress", "Unzipping " + ze.getName());
        if (ze.isDirectory()) {
            throw new UnsupportedOperationException(
                    "currently only flat archives are supported");
...
voiddecompress(InputStream is, OutputStream os)
decompress
GZIPInputStream gis = null;
try {
    gis = new GZIPInputStream(is);
    int count;
    byte data[] = new byte[BUFFER];
    while ((count = gis.read(data, 0, BUFFER)) != -1) {
        os.write(data, 0, count);
} catch (IOException e) {
    System.out.println(e.getMessage());
} finally {
    if (gis != null) {
        try {
            gis.close();
        } catch (IOException e) {
voiddecompress(InputStream is, OutputStream os)
decompress
GZIPInputStream gis = null;
try {
    gis = new GZIPInputStream(is);
    int count;
    byte data[] = new byte[BUFFER];
    while ((count = gis.read(data, 0, BUFFER)) != -1) {
        os.write(data, 0, count);
} catch (IOException e) {
    System.out.println(e.getMessage());
} finally {
    if (gis != null) {
        try {
            gis.close();
        } catch (IOException e) {
voiddecompress(InputStream is, OutputStream os)
decompress
GZIPInputStream gin = new GZIPInputStream(is);
int count;
byte data[] = new byte[BUFFERSIZE];
while ((count = gin.read(data, 0, BUFFERSIZE)) != -1) {
    os.write(data, 0, count);
gin.close();
Stringuncompress(InputStream inputStream)
uncompress
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) {
...
booleanunpackZip(Context context, String s, InputStream is)
Unpack the given InputStream, representing ZIP file, to app cache dir
ZipInputStream zis;
try {
    String filename;
    File cache = context.getCacheDir();
    File dir = new File(cache.getAbsolutePath() + "/" + s);
    dir.mkdir();
    zis = new ZipInputStream(new BufferedInputStream(is));
    ZipEntry ze;
...
InputStreamreadEntryAsWhatEverInternal( final ZipEntry entry, final InputStream unzippedInputStream)
read Entry As What Ever Internal
InputStream is = null;
ZipInputStream zipIs = null;
zipIs = new ZipInputStream(unzippedInputStream);
ZipEntry ze;
while ((ze = zipIs.getNextEntry()) != null) {
    if (ze.getName().equals(entry.getName())) {
        is = zipIs;
        break;
...