我有一个字符串问题,我使用下面的代码从 URL 接收 JSON 数据,代码工作正常,但问题是我没有得到完整的数据,只有一半的 JSON 值来了,我想知道是否这是有原因的,如果是这样意味着如何解决这个问题。JSON字符串很大
DefaultHttpClient http_client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(urls[0]);
HttpResponse response = http_client.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
HttpEntity entity = response.getEntity();
InputStream in = entity.getContent();
StringBuffer out = new StringBuffer();
byte[] b = new byte[4096];
int n = in.read(b);
while(n>0){
out.append(new String(b, 0, n));
n = in.read(b);
}
String resultdata = out.toString();
Log.d("Out data",resultdata);