is NetworkResponse Gzipped - Android File Input Output

Android examples for File Input Output:Zip File

Description

is NetworkResponse Gzipped

Demo Code


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import com.android.volley.NetworkResponse;

public class Main{
    public static final String HEADER_ENCODING = "Content-Encoding";
    public static final String ENCODING_GZIP = "gzip";
    /*ww  w. j a  v  a  2 s .  c om*/
    public static boolean isGzipped(NetworkResponse response) {
        Map<String, String> headers = response.headers;
        return headers != null
                && !headers.isEmpty()
                && (headers.containsKey(HEADER_ENCODING) && headers.get(
                        HEADER_ENCODING).equalsIgnoreCase(ENCODING_GZIP));
    }
}

Related Tutorials