0

I'm creating a StringBuilder with it's initial capacity to be 8192 and appending lines to fill it with a little under 6000 characters in this case.

When I write the StringBuilder.toString() value out to the log it cuts off the last 1/4 or so of the whole String. This isn't the first time I've noticed android doing this with strings of similarly large sizes written out to the log.

When I run the same in java on a Linux desktop machine, I've no such problem / behaviour - everything is written out.

Is there some sort of limit I don't know about? Do I have to write out everything line by line in separate calls?

Thank you.

Peter Flower
  • 363
  • 2
  • 20
  • the key part that you missed is "to the log" – njzk2 Apr 25 '17 at 14:38
  • Indeed - it was rather stupid of me to think of the problem - & subsequently describe it - as I did. After further research into logcat and seeing the offered answers from other users I see now it is an issue with what logcat will accept for output and not the java. – Peter Flower Apr 25 '17 at 14:43

2 Answers2

1

Is Android java StringBuilder limit 4096 characters?

No.

Is there some sort of limit I don't know about?

Yes. LogCat will not log arbitrarily-long messages.

Do I have to write out everything line by line in separate calls?

Well, I would log something smaller, or perform other sorts of diagnostics. But, yes, you could split the string into chunks and log those chunks individually.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
1

This is a debugger issue, the full content should be there but not everything is displayed

See: https://stackoverflow.com/a/43537128/2890156

Community
  • 1
  • 1
Denny
  • 1,766
  • 3
  • 17
  • 37