How to display long messages in logcat

后端 未结 10 1064
轻奢々
轻奢々 2020-11-29 01:08

I am trying to display long message on logcat. If the length of message is more than 1000 characters, it gets broken.

What is the mechanism to show all characters o

10条回答
  •  生来不讨喜
    2020-11-29 01:25

    This builds on spatulamania's answer, is a little more succinct, and won't add an empty log message at the end:

    final int chunkSize = 2048;
    for (int i = 0; i < s.length(); i += chunkSize) {
        Log.d(TAG, s.substring(i, Math.min(s.length(), i + chunkSize)));
    }
    

提交回复
热议问题