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

  • SEARCH
  • Home
  • 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 7521405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:13:49+00:00 2026-05-30T02:13:49+00:00

I have a weird error in my code. I’m trying to read some characters

  • 0

I have a weird error in my code. I’m trying to read some characters from InputStreamReader using char buffer and appending it to StringBuilder.

The snippet is here:

char[] buffer = new char[4096];
int numRead = 0;
webResource = new StringBuilder("");
while ( (numRead = reader.read(buffer, 0, 4096)) != -1 )
            {
                System.out.println("Capacity before: "+webResource.capacity());
                webResource.append(buffer, 0, numRead);
                System.out.println("Capacity after: "+webResource.capacity());
            }

The System.out.println() is only for debug purpose.

I’m trying to read InputStream that have 147 781 chars. First two times in while cycle is everything ok, I read characters into buffer and then it is appended to webResource (StringBuilder).

But at the third iteration I read to buffer 4096 characters but only 1446 characters are appended to webResource (StringBuilder).

I’ve been debugging the code in Eclipse and while watching variable webResource I find out that, after third iteration (after appendding 1446 characters) the content of variable simply ends with “…” and no new characters are added in next iterations.

Weird thing also is, that webResource.count is incementing properly (after four interations its value is 16 384, and so on).

Pleas can anyone help? I really do not see where is the problem of why I can’t append whole inputstream to StringBuilder, I can only append the first 9 638 characters.

Thanks in advance.

  • 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-30T02:13:49+00:00Added an answer on May 30, 2026 at 2:13 am

    You seem to be misinterpreting what you see in the debugger. The debugger is not showing you the whole content of the stringbuilder because it’s too long. but it’s all there.,

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

Sidebar

Related Questions

I have come across a very weird error. I'm on Solaris 10, using Ruby
Hey guys I have a weird error I wrote this code against setbubblepopup $(document).ready(function
I keep getting some weird error in Processing, using the following tiny piece of
I have a very weird problem while trying to pass and SQL query using
I have a weird error I'm trying to debug with no luck. I have
I am having a weird error when using Omniauth. This appears to have little
I have just got weird error which involves protected modifier. I have following code:
I'm getting an weird error using queues/multiprocessing. I basically have a function that takes
I'm trying to add some contacts from an xml file which have been serialize
I have a weird error in my C++ classes at the moment. I have

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.