gpt4 book ai didi

android - 如何在logcat中显示长消息

转载 作者:IT老高 更新时间:2023-10-28 13:10:16 24 4
gpt4 key购买 nike

我正在尝试在 logcat 上显示长消息。如果消息的长度超过 1000 个字符,它就会被破坏。

logcat中长信息全部显示的机制是什么?

最佳答案

如果 logcat 将长度限制为 1000,那么您可以使用 String.subString() 拆分要记录的字符串并将其分段记录。例如:

int maxLogSize = 1000;
for(int i = 0; i <= veryLongString.length() / maxLogSize; i++) {
int start = i * maxLogSize;
int end = (i+1) * maxLogSize;
end = end > veryLongString.length() ? veryLongString.length() : end;
Log.v(TAG, veryLongString.substring(start, end));
}

关于android - 如何在logcat中显示长消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7606077/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com