Android Reading from an Input stream efficiently

Posted by RenegadeAndy on Stack Overflow See other posts from Stack Overflow or by RenegadeAndy
Published on 2010-03-22T12:15:39Z Indexed on 2010/03/22 12:21 UTC
Read the original article Hit count: 242

Filed under:
|
|
|

Hey,

I am making an HTTP get request to a website for an android application I am making.

I am using a DefaultHttpClient and using HttpGet to issue the request. I get the entity response and from this obtain an InputStream object for getting the html of the page.

I then cycle through the reply doing as follows:

BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
String x = "";
x = r.readLine();
String total = "";

while(x!= null){
total += x;
x = r.readLine();
}

However this is horrendously slow.

Is this inefficient? I'm not loading a big web page - www.cokezone.co.uk so the file size is not big. Is there a better way to do this?

Thanks

Andy

© Stack Overflow or respective owner

Related posts about android

Related posts about bufferedreader