Observe very long String content in Eclipse

2019-06-16 14:33发布

问题:

Since LogCat truncates long strings, I work around this using FileOutputStream to inspect the contents of very long strings.

It works but it forces me to 'adb pull' that file, which is not very convenient, compare to watching it on LogCat.

Is there any other way in Eclipse to watch very long strings?

回答1:

For the record, the answer was found here.



回答2:

when you stop in debug on the variable do the following and past it to a text file



回答3:

I think it will be easier to use the eclipse debugging view.

Set a break point at the line where you call Log.* and run your app in debug mode. When execution reaches the break point the app will ... yes, it will halt.

In the Variables window you may now browse your data and display whatever you need. Copy and paste it at a safe place as well and don't forget to smile :)



回答4:

What I do, is in "Variables->Change value".

That will show you a Windows with the full text. Then just Copy&paste to notepad.



回答5:

try this:

public void logLargeString(String str) {

    if(str.length() > 3000) {
        Log.i(TAG, str.substring(0, 3000));
        logLargeString(str.substring(3000));
    } else
        Log.i(TAG, str);
    }
}