Android InputStream Zip compress(InputStream is, OutputStream os)

Here you can find the source of compress(InputStream is, OutputStream os)

Description

compress

Declaration

public static void compress(InputStream is, OutputStream os)
        throws Exception 

Method Source Code

//package com.java2s;
import java.io.InputStream;
import java.io.OutputStream;

import java.util.zip.GZIPOutputStream;

public class Main {
    static final int BUFFERSIZE = 1024;

    public static void compress(InputStream is, OutputStream os)
            throws Exception {
        GZIPOutputStream gos = new GZIPOutputStream(os);
        int count;
        byte data[] = new byte[BUFFERSIZE];
        while ((count = is.read(data, 0, BUFFERSIZE)) != -1) {
            gos.write(data, 0, count);//from ww w . j a va  2  s. c  o  m
        }
        gos.flush();
        gos.finish();
        gos.close();
    }
}

Related

  1. unZipTo(InputStream paramInputStream, String paramString)
  2. compress(InputStream is, OutputStream os)
  3. compress(InputStream is, OutputStream os)