Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
445 views
in Technique[技术] by (71.8m points)

java - Is there a limit to how much of a string Logcat will print?

I'm trying to figure out whether my code is pulling the whole of an RSS feed by printing the result to logcat, but it appears to only display so much of the aforementioned string. So I'm trying to figure out if theres a problem with the code or whether logcat has a limit on large strings.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I believe it caps the string on 1000 characters. You could split the string and then log it piece by piece like below :

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

hope this helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...