Java tutorial
//package com.java2s; import java.io.IOException; import java.io.InputStream; import java.net.URLConnection; import java.util.zip.GZIPInputStream; import java.util.zip.Inflater; import java.util.zip.InflaterInputStream; public class Main { public static InputStream getInputEncoding(URLConnection connection) throws IOException { InputStream in; String encoding = connection.getContentEncoding(); if (encoding != null && encoding.equalsIgnoreCase("gzip")) { in = new GZIPInputStream(connection.getInputStream()); } else if (encoding != null && encoding.equalsIgnoreCase("deflate")) { in = new InflaterInputStream(connection.getInputStream(), new Inflater(true)); } else { in = connection.getInputStream(); } return in; } }