im lookin way to read big json content from url. Im write simple app where i test much funcitons . Most function show me time ~40-45 seconds. Than return content(JSON file realy big) Size of JSON FILE 90kb .. 2600 lines First funciton reading all content but very slow (40-45 seconds)
public String readJsonFromUrl(String urls) {
String content = "";
URL myLink = null;
String inputLine=null;
try {
myLink = new URL(urls);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
}
BufferedReader in = null;
try {
in = new BufferedReader(
new InputStreamReader(
myLink.openStream()));
} catch (IOException e) {
}
try {
while ((inputLine = in.readLine()) != null)
content =content+inputLine;
} catch (IOException e1) {
// TODO Auto-generated catch block
}
try {
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return content;
}
Function work perfect. But time :(. U guys can just input fucn to code , set url and parse.
Second function
public void readJSONFromUrl(String urls) throws IOException, URISyntaxException
{
InputStream is = null;
String response = "";
String url=urls;
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
HttpGet httpGet = new HttpGet(url);
httpResponse = httpClient.execute(httpGet);
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);
Log.i("RESPONSE","RESPONSE = "+response);
}
this funciton work but very strange. i get only PART of content and very small part of big content.
Anyone maybe know some thing better or how to fix second function for test .. it's show me how much time need for getting content. Or maybe some one have other fucntion which faste than two this function ? Regards Peter.