gunzip - How can i decompress my json data using gzip format in android? -


i want decompress json data , store string.i tried more not working well.

i called jsonparser class activity raised error when run application.

here, jsonparse.java

public class jsonparse {     static string res=null;     public final static int = 1;     public final static int post = 2;     inputstreamreader reader = null;     bytearrayinputstream bais=null;     gzipinputstream gzis=null;     bufferedreader in=null;     string str="";     string outstr="";     public jsonparser() {      }      public string makeservicecall(string url, int method,                                   list<namevaluepair> params) {         try {             defaulthttpclient httpclient = new defaulthttpclient();             httpentity httpentity = null;             httpresponse httpresponse = null;              if (method == post) {                 httppost httppost = new httppost(url);                 if (params != null) {                     httppost.setentity(new urlencodedformentity(params));                 }                 httpresponse = httpclient.execute(httppost);              } else if (method == get) {                 if (params != null) {                     string paramstring = urlencodedutils                             .format(params, "utf-8");                     url += "?" + paramstring;                 }                  httpget httpget = new httpget(url);                 httpresponse = httpclient.execute(httpget);             }               httpentity = httpresponse.getentity();             res=entityutils.tostring(httpentity);               bais=new bytearrayinputstream(res.getbytes("utf-8"));             gzis=new gzipinputstream(bais);             reader=new inputstreamreader(gzis,"utf-8");             bufferedreader in = new bufferedreader(reader);              stringbuilder sb = new stringbuilder();             string line = null;             outstr="";             while ((line = in.readline()) != null) {                  outstr+=line;             }             log.e("outstr",""+outstr);             reader.close();           } catch (unsupportedencodingexception e) {             e.printstacktrace();         } catch (clientprotocolexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         }         return outstr;     }  } 

here, error

w/system.err: java.io.ioexception: unknown format (magic number ef1f) @ java.util.zip.gzipinputstream.<init>(gzipinputstream.java:109) @ java.util.zip.gzipinputstream.<init>(gzipinputstream.java:88) @ comman.servicehandler.makeservicecall(servicehandler.java:77) 

please, me solve out error.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -