我正在构建一个使用Android中的JSON从服务器获取数据的应用程序。有大约3000个记录被提取,加载似乎相当慢。获取数据的代码如下 -
public static String executeHttpGet(String url) throws Exception {
BufferedReader in = null;
try {
HttpClient client = getHttpClient();
HttpGet request = new HttpGet();
request.setURI(new URI(url));
HttpResponse response = client.execute(request);
// in = new BufferedReader(new InputStreamReader(response.getEntity()
// .getContent()));
in = new BufferedReader(new InputStreamReader(response.getEntity()
.getContent(), "UTF-8"));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null) {
sb.append(line + NL);
}
in.close();
String result = sb.toString();
return result;
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
Log.e("log_tag", "Error converting result " + e.toString());
e.printStackTrace();
}
}
}
有什么办法可以加快取物速度吗?提前谢谢。
答案 0 :(得分:0)