1

for some reason, when I take a string from my server to my app and Log it, the string is shorter than it needs to be.
I thought that it is happening because of the length of the string, but the whole string is 113137 characters long (and the limit is 10^32 -1).
The length of the string that returns to me is something like 4000.

Code:

BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(IS));
StringBuilder stringBuilder = new StringBuilder();
String line = "";

while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line);
}

Log.d("Base64", stringBuilder.toString());
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • 1
    Logcat truncates Strings that are "too long", make sure it's not this. http://stackoverflow.com/questions/8888654/android-set-max-length-of-logcat-messages – Ken Wolf Mar 20 '16 at 17:40
  • By the way, also append a newline for every line, as readLine strips these. – Joop Eggen Mar 20 '16 at 17:41
  • Yes, as told by others logcat truncates the long string and prints... How you are saying that you received string length is 4000?? Please print the length using string.length() and confirm you received what you expected – Dinash Mar 20 '16 at 17:52
  • Thanks, you're right –  Mar 22 '16 at 16:38

1 Answers1

1

There is limit on log message length

#define LOGGER_ENTRY_MAX_LEN        (4*1024)
#define LOGGER_ENTRY_MAX_PAYLOAD (LOGGER_ENTRY_MAX_LEN - sizeof(struct logger_entry))

Also look at following question to clarify things Android - Set max length of logcat messages

Community
  • 1
  • 1
v4_adi
  • 1,503
  • 1
  • 12
  • 14