Read gzip response from a URL using Java

Here is a code template.....

public static String readGZFile(String url) throws IOException {
           StringBuffer dataBuffer =new StringBuffer();
           InputStream gzipStream = new GZIPInputStream((new URL(url)).openStream());
           Reader decoder = new InputStreamReader(gzipStream, "UTF-8");
           BufferedReader buffered = new BufferedReader(decoder);
           int i=0;
           String line=buffered.readLine();
           while(line !=null){
               dataBuffer.append(line);
               line=buffered.readLine();
               i++;
           }       
           return dataBuffer.toString();          
    }

Popular posts from this blog

Can not connect to git using ssh (Permissions 0644 for '/root/.ssh/id_rsa' are too open.

Upload file on Google cloud storage using Java servlet on google app engine

Android: where to run keytool command in android