Explicitly stating the buffer size to use (8000) is recommended by the BufferedReader API. If you don't do this it will throw warnings in the log suggesting that you do. Of course you could use a different size buffer (e.g. if you know your content is much less than that size).
For very large content (in MB or more) and streams (or other unknown content sizes), web servers will chunk the content<http://en.wikipedia.org/wiki/Chunked_transfer_encoding>, and you'll need to detect this and gather the parts.You can check the headers returned in the response to detect for this. However, I doubt this is happening in your case. I have built android apps that pull MB of data over HTTP, so I don't think there's an inherent limit in the android framework here. You could directly using Stream.read instead of using a reader if you want to test this without the middle layers (removes the question of readLine failing for other reasons, if that's possible). InputStream proxyStream = http.getContent(); try { int readBytesProxy = -1; byte[] buffProxy = new byte[1024 * 50]; while ((readBytesProxy = proxyStream.read(buffProxy)) != -1) { // Do something with your data } } catch (Exception ex) { Log.e(TAG, "Error streaming file content", ex); } finally { if (proxyStream != null) { proxyStream.close(); } } Also, check your server too. Try pulling the source with curl or wget and see if you get more than the 5k that you get with the app. -- Jeremy Wadsack On Fri, Aug 27, 2010 at 9:32 AM, DanH <[email protected]> wrote: > I certainly hope that available Android memory is more than 3000 > characters. > > On Aug 27, 5:14 am, Droid <[email protected]> wrote: > > I think you are hitting a capacity limit of the android and should > > chunk it somehow at say 3000 chars and store the chars somewhere not > > in memory. > > Droid > > > > On Aug 27, 12:13 am, Achanta <[email protected]> wrote: > > > > > I Tested your suggestions by setting UTF-8 and I also tried the same > > > by removing the length 8000. But it still does the same thing. > > > Thank you for the response though. > > > > > This thing is driving me nuts. > > > > > On Aug 26, 4:58 pm, Jake Radzikowski <[email protected]> > > > wrote:> reader = new BufferedReader(new InputStreamReader(inputStream), > 8000); I'm > > > > gunna guess that 8000 has something to do with it :). I usually use > the > > > > following: > > > > > > reader = new BufferedReader(new InputStreamReader(inputStream, > "UTF-8")); > > > > > > On Thu, Aug 26, 2010 at 3:40 PM, Achanta <[email protected]> > wrote: > > > > > > > I am trying to get a JSON response from our server and the response > > > > > string seems is always being truncated when the string length > reaches > > > > > to around 5525 characters. > > > > > > > HttpClient httpClient = new DefaultHttpClient(); > > > > > HttpPost post = new HttpPost(URL); > > > > > ResponseHandler<String> responseHandler= new > BasicResponseHandler(); > > > > > String testResponse = httpClient.execute(post, responseHandler); > > > > > > > I also tried this by using HttpEntity and reading the response > stream. > > > > > But that also truncates the string at approximately that length. > > > > > > > HttpClient httpClient = new DefaultHttpClient(); > > > > > HttpPost post = new HttpPost(URL); > > > > > // HttpGet get = new HttpGet(URL); > > > > > > > HttpResponse response = null; > > > > > HttpEntity entity = null; > > > > > InputStream inputStream = null; > > > > > BufferedReader reader = null; > > > > > String result = ""; > > > > > try { > > > > > response = (HttpResponse)httpClient.execute(post); > > > > > entity = response.getEntity(); > > > > > if(entity != null){ > > > > > inputStream = entity.getContent(); > > > > > } > > > > > reader = new BufferedReader(new > > > > > InputStreamReader(inputStream), 8000); > > > > > StringBuffer builder = new StringBuffer(""); > > > > > String line = reader.readLine(); > > > > > while(line != null){ > > > > > Log.v(tag, "int max::::::::: > "+Integer.MAX_VALUE); > > > > > Log.v(tag, "LINE::::::::: "+line > > > > > +reader.toString()); > > > > > Log.v(tag, "reader::::::::: > "+reader.toString()); > > > > > builder.append(line+"\n"); > > > > > line = reader.readLine(); > > > > > } > > > > > inputStream.close(); > > > > > result = builder.toString(); > > > > > } catch (ClientProtocolException e) { > > > > > e.printStackTrace(); > > > > > } catch (IOException e) { > > > > > e.printStackTrace(); > > > > > } finally{ > > > > > if(inputStream != null){ > > > > > try{ > > > > > inputStream.close(); > > > > > }catch(IOException e){ > > > > > e.printStackTrace(); > > > > > } > > > > > } > > > > > } > > > > > > > Please let me know how I can handle this problem. I used this post > as > > > > > the reference while creating this. > > > > > > > > http://senior.ceng.metu.edu.tr/2009/praeda/2009/01/11/a-simple-restfu... > > > > > > > I tested the link in my browser and it does return the complete > JSON. > > > > > So I am sure the issue is with my code in android. > > > > > > > Thank you. > > > > > > > -- > > > > > You received this message because you are subscribed to the Google > > > > > Groups "Android Developers" group. > > > > > To post to this group, send email to > [email protected] > > > > > To unsubscribe from this group, send email to > > > > > [email protected]<android-developers%[email protected]><android-developers%2Bunsubs > [email protected]> > > > > > For more options, visit this group at > > > > >http://groups.google.com/group/android-developers?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

