java - Base64 image data is not getting in android -
i using httpurlconnection
connect server , response contains base64
image data. when trying read response using getinputstream
not reading complete response, breaks in between. response contains list of objects in json format , each object contains base64 image data. reading breaks while trying read first image data first object. though not showing error displays till half of image data.how full response?? here code
inputstream = httpurlconnection.getinputstream(); byte[] b = new byte[1024]; stringbuffer buffer=new stringbuffer(); while ( is.read(b) != -1){ buffer.append(new string(b)); system.out.println("read= "+is.read()); } system.out.println(buffer);
have tried example code google?
url url = new url("http://www.android.com/"); httpurlconnection urlconnection = (httpurlconnection) url.openconnection(); try { inputstream in = new bufferedinputstream(urlconnection.getinputstream()); readstream(in); } { urlconnection.disconnect(); }
where readstream
own method.
reading bufferedinputstream
easier , faster.
Comments
Post a Comment