简体   繁体   English

Android如何在logcat中查看长字符串

[英]Android how to view long string in logcat

I have a HashMap<String, LinkedHashMap<String,String> that is fairly long (not an issue) and I'm trying to make sure things look correct before I use the data inside it. 我有一个HashMap<String, LinkedHashMap<String,String>这个很长(不是问题),我试图确保在我使用其中的数据之前看起来正确。 To do this I'm trying to just attempting to do this Log.v("productsFromDB",products.toString()) but in the LogCat It shows about 1/3 of it. 为此,我试图尝试执行此Log.v("productsFromDB",products.toString())但在LogCat它显示大约1/3。 Is there a way to output the entire map? 有没有办法输出整个地图?

Logcat can only show about 4000 characters. Logcat只能显示大约4000个字符。 So you need to call a recursive function to see the entire hashmap. 因此,您需要调用递归函数来查看整个hashmap。 Try this function: 试试这个功能:

public static void longLog(String str) {
    if (str.length() > 4000) {
        Log.d("", str.substring(0, 4000));
        longLog(str.substring(4000));
    } else
        Log.d("", str);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM