Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1020423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:09:51+00:00 2026-05-16T11:09:51+00:00

I am trying to get a JSON response from our server and the response

  • 0

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-restful-client-at-android/

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:09:51+00:00Added an answer on May 16, 2026 at 11:09 am

    First of all thanks everyone for replying.

    I just discovered that the problem is not with my code but with the number of lines that the logcat is displaying.
    The problem was that I got a problem in my json reply format and my parsing code spits an error. So I started trying to debug it by printing the response json string in logcat. This is being truncated always and I was guessing till now that the response from server itself is being truncated.

    So today I started playing with the response string builder and has to write funny snippets to count characters and detect the characters at positions I was expecting and I found that the response was being returned completely.
    I also tested my code on some other large stings and I discovered that the logcat has a limit on the length of the string that it displays or at least it looked so. That was why my responses were being displayed as truncated strings and I thought that its the problem with my code.

    So it is working fine as the code is earlier and the only problem was
    that the logcat does not display the complete string. But it does not
    bother me[atleast right now].

    Thanks again everyone for trying to help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're using jQuery to get a JSON-string from our server (UTF-8 response, also UTF-8
I am trying to deserialize a json response from a google api, so i
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
Whilst trying to get our app working in Firefox (I'm a big proponent of
Just trying to get my head around Generics by reading this enlightening article by
Im trying to get a completly data copy from a gridview, itryed clone(), tryed
I'm trying to get my head around Cappuccino. I'd like my StackOverview peers to
I have validated the JSON response from my C# Webmethod, so I don't believe
I'm using global variables to pass around a response from a AJAX call: window.response

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.